Class: Enterprisifier::Marshalling::InstantiatableElement::AssociationProxy
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Enterprisifier::Marshalling::InstantiatableElement::AssociationProxy
- Defined in:
- lib/enterprisifier/marshalling/instantiatable_element.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(parent, element_klass) ⇒ AssociationProxy
constructor
A new instance of AssociationProxy.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(parent, element_klass) ⇒ AssociationProxy
Returns a new instance of AssociationProxy.
8 9 10 11 12 |
# File 'lib/enterprisifier/marshalling/instantiatable_element.rb', line 8 def initialize(parent, element_klass) @parent = parent @collection = [] @element_klass = element_klass end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
21 22 23 |
# File 'lib/enterprisifier/marshalling/instantiatable_element.rb', line 21 def method_missing(sym, *args, &block) @collection.send(sym, *args, &block) end |
Instance Method Details
#build ⇒ Object
14 15 16 17 18 19 |
# File 'lib/enterprisifier/marshalling/instantiatable_element.rb', line 14 def build @element_klass.new.tap do |e| e.parent = @parent @collection << e end end |