Class: Enterprisifier::Marshalling::InstantiatableElement::AssociationProxy

Inherits:
BlankSlate
  • Object
show all
Defined in:
lib/enterprisifier/marshalling/instantiatable_element.rb

Instance Method Summary collapse

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

#buildObject



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