lib/puffer/controller/dsl.rb in puffer-0.0.25 vs lib/puffer/controller/dsl.rb in puffer-0.0.26

- old
+ new

@@ -3,13 +3,13 @@ module Dsl extend ActiveSupport::Concern included do class_attribute :_members - self._members = Puffer::Controller::Actions.new + self._members = Puffer::Controller::Actions.new :member class_attribute :_collections - self._collections = Puffer::Controller::Actions.new + self._collections = Puffer::Controller::Actions.new :collection class_attribute :_fieldset_fallbacks self._fieldset_fallbacks = HashWithIndifferentAccess.new helper_method :_members, :_collections end @@ -28,14 +28,16 @@ klass._fieldset_fallbacks = Marshal.load(Marshal.dump(_fieldset_fallbacks)) super end def member &block + _members.controller = self block.bind(_members).call if block_given? end def collection &block + _collections.controller = self block.bind(_collections).call if block_given? end def define_fieldset *actions options = actions.extract_options! @@ -48,13 +50,15 @@ send "_#{action}_fields=", Puffer::FieldSet.new unless send("_#{action}_fields?") helper_method "#{action}_fields" self.class.instance_eval do define_method action do |&block| + @_super_fields = send("_#{action}_fields") @_fields = send("_#{action}_fields=", Puffer::FieldSet.new(action)) block.call if block remove_instance_variable :@_fields + remove_instance_variable :@_super_fields end define_method "#{action}_fields" do actions = self._fieldset_fallbacks[action].dup last = actions.pop @@ -74,10 +78,13 @@ send "#{set}_fields" end def field name, options = {}, &block field = @_fields.field(name, model, options, &block) if @_fields - #generate_association_actions field if field.reflection + end + + def super_fields + @_super_fields.copy_to @_fields, model if @_super_fields && @_fields end end end