Class: ActiveShepherd::ApplyMethod
- Defined in:
- lib/active_shepherd/method.rb
Instance Attribute Summary collapse
-
#meta_action ⇒ Object
readonly
Returns the value of attribute meta_action.
Attributes inherited from Method
#aggregate, #associations, #attributes
Instance Method Summary collapse
Methods inherited from Method
inherited, #initialize, #recurse, #traverse!
Constructor Details
This class inherits a constructor from ActiveShepherd::Method
Instance Attribute Details
#meta_action ⇒ Object (readonly)
Returns the value of attribute meta_action.
51 52 53 |
# File 'lib/active_shepherd/method.rb', line 51 def @meta_action end |
Instance Method Details
#create? ⇒ Boolean
53 54 55 |
# File 'lib/active_shepherd/method.rb', line 53 def create? == :_create end |
#destroy? ⇒ Boolean
57 58 59 |
# File 'lib/active_shepherd/method.rb', line 57 def destroy? == :_destroy end |
#setup(hash) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_shepherd/method.rb', line 61 def setup(hash) hash.each do |key, value| traversable_association = aggregate.traversable_associations[key] if traversable_association.present? associations[key] = [traversable_association, value] elsif aggregate.untraversable_association_names.include? key elsif [:_create, :_destroy].include? key @meta_action = key elsif aggregate.raw_attributes.keys.include? key.to_s attributes[key] = value else raise ActiveShepherd::AggregateMismatchError, "Attribute `#{key}' "\ "invalid for `#{aggregate.model.class.name}'" end end end |