Class: Yaoc::ManyToOneMapperChain

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*converter) ⇒ ManyToOneMapperChain

Returns a new instance of ManyToOneMapperChain.



9
10
11
# File 'lib/yaoc/many_to_one_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/many_to_one_mapper_chain.rb', line 3

def converter
  @converter
end

#last_resultObject

Returns the value of attribute last_result.



3
4
5
# File 'lib/yaoc/many_to_one_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/many_to_one_mapper_chain.rb', line 3

def next_result
  @next_result
end

Class Method Details

.registryObject



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

def self.registry
  Yaoc::MapperRegistry
end

Instance Method Details

#dump_all(input_objects, object_to_fill = nil) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/yaoc/many_to_one_mapper_chain.rb', line 41

def dump_all(input_objects, object_to_fill = nil)
  each_object_with_converter(input_objects) do |converter, input_object|
    object_to_fill = converter.dump(input_object, object_to_fill)
  end

  self.last_result = object_to_fill
end

#dump_first(input_object, object_to_fill = nil) ⇒ Object



32
33
34
35
# File 'lib/yaoc/many_to_one_mapper_chain.rb', line 32

def dump_first(input_object, object_to_fill = nil)
  converter_iterator.rewind
  self.next_result = converter_iterator.next.dump(input_object, object_to_fill)
end

#dump_next(input_object) ⇒ Object



37
38
39
# File 'lib/yaoc/many_to_one_mapper_chain.rb', line 37

def dump_next(input_object)
  self.next_result = converter_iterator.next.dump(input_object, next_result)
end

#load_all(input_objects, object_to_fill = nil) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/yaoc/many_to_one_mapper_chain.rb', line 24

def load_all(input_objects, object_to_fill = nil)
  each_object_with_converter(input_objects) do |converter, input_object|
    object_to_fill = converter.load(input_object, object_to_fill)
  end

  self.last_result = object_to_fill
end

#load_first(input_object, object_to_fill = nil) ⇒ Object



13
14
15
16
# File 'lib/yaoc/many_to_one_mapper_chain.rb', line 13

def load_first(input_object, object_to_fill = nil)
  converter_iterator.rewind
  self.next_result = converter_iterator.next.load(input_object, object_to_fill)
end

#load_next(input_object) ⇒ Object



18
19
20
21
22
# File 'lib/yaoc/many_to_one_mapper_chain.rb', line 18

def load_next(input_object)
  self.next_result = converter_iterator.next.load(input_object, next_result)
rescue StopIteration
  raise 'ToManyInputObjects'
end