Class: Synapse::Upcasting::UpcasterChain

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/upcasting/upcaster_chain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(converter_factory) ⇒ undefined



12
13
14
15
# File 'lib/synapse/upcasting/upcaster_chain.rb', line 12

def initialize(converter_factory)
  @converter_factory = converter_factory
  @upcasters = Array.new
end

Instance Attribute Details

#converter_factoryConverterFactory (readonly)



5
6
7
# File 'lib/synapse/upcasting/upcaster_chain.rb', line 5

def converter_factory
  @converter_factory
end

#upcastersArray<Upcaster> (readonly)



8
9
10
# File 'lib/synapse/upcasting/upcaster_chain.rb', line 8

def upcasters
  @upcasters
end

Instance Method Details

#push(upcaster) ⇒ undefined Also known as: <<

Pushes the given upcaster onto the end of this upcaster chain



21
22
23
# File 'lib/synapse/upcasting/upcaster_chain.rb', line 21

def push(upcaster)
  @upcasters.push upcaster
end

#upcast(serialized_object, upcast_context) ⇒ Array<SerializedObject>



30
31
32
33
34
35
36
37
38
39
# File 'lib/synapse/upcasting/upcaster_chain.rb', line 30

def upcast(serialized_object, upcast_context)
  serialized_objects = Array.new
  serialized_objects.push serialized_object

  @upcasters.each do |upcaster|
    serialized_objects = upcast_objects upcaster, serialized_objects, upcast_context
  end

  serialized_objects
end