add active admin and more code work

This commit is contained in:
John Bintz 2013-07-29 16:34:52 -04:00
parent d910e0e837
commit fb93632750
4 changed files with 23 additions and 3 deletions

View File

@ -44,8 +44,12 @@ class DatabaseObjectFormObject < CandyWrapper::ModelWrapper
end end
``` ```
## Coming soon! Also, plug it into ActiveAdmin super-easily, which is where I typicallty
use it!
* Form objects that hang off of models as if they were relationships ``` ruby
* A better readme! ActiveAdmin.register Model do
wrap_in_form_object
end
```

View File

@ -2,3 +2,6 @@ require "candy_wrapper/version"
require "candy_wrapper/model_wrapper" require "candy_wrapper/model_wrapper"
require "candy_wrapper/inherited_resources" require "candy_wrapper/inherited_resources"
if defined?(ActiveAdmin)
require 'candy_wrapper/active_admin'
end

View File

@ -0,0 +1,9 @@
class ActiveAdmin::DSL
def wrap_in_form_object
controller do
include CandyWrapper::InheritedResources
wrap_in_form_object!
end
end
end

View File

@ -55,6 +55,10 @@ module CandyWrapper
end end
def save def save
if respond_to? :before_wrapped_save
before_wrapped_save @__object__
end
self.class.before_wrapped_save.each do |before| self.class.before_wrapped_save.each do |before|
send("#{before}=", @__object__, @__params__[before]) send("#{before}=", @__object__, @__params__[before])
end end