Class: Yaoc::OneToManyMapperChain

Inherits:
Object
  • Object
show all
Defined in:
lib/yaoc/one_to_many_mapper_chain.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*converter) ⇒ OneToManyMapperChain

Returns a new instance of OneToManyMapperChain.



9
10
11
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 9

def initialize(*converter)
  self.converter = converter
end

Instance Attribute Details

#converterObject

Returns the value of attribute converter.



3
4
5
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 3

def converter
  @converter
end

#last_resultObject

Returns the value of attribute last_result.



3
4
5
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 3

def last_result
  @last_result
end

#next_resultObject

Returns the value of attribute next_result.



3
4
5
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 3

def next_result
  @next_result
end

Class Method Details

.registryObject



5
6
7
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 5

def self.registry
  Yaoc::MapperRegistry
end

Instance Method Details

#dump_all(input_object, objects_to_fill = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 24

def dump_all(input_object, objects_to_fill = nil)
  objects_to_fill = Array(objects_to_fill)
  results = []

  each_object_with_converter(objects_to_fill) do |converter, object_to_fill|
    results << converter.dump(input_object, object_to_fill)
  end

  self.last_result = results
end

#load_all(input_object, objects_to_fill = []) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/yaoc/one_to_many_mapper_chain.rb', line 13

def load_all(input_object, objects_to_fill = [])
  objects_to_fill = Array(objects_to_fill)
  results = []

  each_object_with_converter(objects_to_fill) do |converter, object_to_fill|
    results << converter.load(input_object, object_to_fill)
  end

  self.last_result = results
end