Class: ActiveShepherd::Method
- Inherits:
-
Object
- Object
- ActiveShepherd::Method
- Defined in:
- lib/active_shepherd/method.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#aggregate ⇒ Object
readonly
Returns the value of attribute aggregate.
-
#associations ⇒ Object
readonly
Returns the value of attribute associations.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Method
constructor
A new instance of Method.
- #recurse(model, foreign_key) ⇒ Object
- #traverse! ⇒ Object
Constructor Details
#initialize(*args) ⇒ Method
Returns a new instance of Method.
16 17 18 19 20 21 22 |
# File 'lib/active_shepherd/method.rb', line 16 def initialize(*args) @aggregate = args.shift @associations = {} @attributes = {} setup *args end |
Instance Attribute Details
#aggregate ⇒ Object (readonly)
Returns the value of attribute aggregate.
14 15 16 |
# File 'lib/active_shepherd/method.rb', line 14 def aggregate @aggregate end |
#associations ⇒ Object (readonly)
Returns the value of attribute associations.
3 4 5 |
# File 'lib/active_shepherd/method.rb', line 3 def associations @associations end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/active_shepherd/method.rb', line 3 def attributes @attributes end |
Class Method Details
.inherited(base) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/active_shepherd/method.rb', line 5 def self.inherited(base) # If you're looking for magic, you've come to the right place return unless base.name.match /Methods::/ apply_or_query, state_or_changes = base.name.demodulize.underscore.split('_', 2) method_name = "#{apply_or_query}_#{state_or_changes}" action_proc = ->(*args) { new(*args).send(method_name) } base.singleton_class.send :define_method, method_name, &action_proc end |