class Synapse::Configuration::UpcasterChainDefinitionBuilder
Definition
builder used to create an upcaster chain
Note that order is very important when building an upcaster chain; the container maintains order when upcasters are registered as service definitions.
@example The minimum possible effort to build an upcaster chain
upcaster_chain
@example Create an upcaster chain using a different identifier and properties
upcaster_chain :alt_upcaster_chain do use_converter_factory :alt_converter_factory use_upcaster_tag :alt_upcaster end
@example Register an upcaster that will be picked up by an upcaster chain
factory :administrative_details_upcaster, :tag => :upcaster do AdministrativeDetailsUpcaster.new end
Public Instance Methods
use_converter_factory(converter_factory)
click to toggle source
Changes the converter factory
@see Serialization::ConverterFactory
@param [Symbol] converter_factory @return [undefined]
# File lib/synapse/configuration/component/upcasting/upcaster_chain.rb, line 27 def use_converter_factory(converter_factory) @converter_factory = converter_factory end
use_upcaster_tag(upcaster_tag)
click to toggle source
Changes the tag to use to automatically register upcasters
@see Upcasting::Upcaster
@param [Symbol] upcaster_tag @return [undefined]
# File lib/synapse/configuration/component/upcasting/upcaster_chain.rb, line 36 def use_upcaster_tag(upcaster_tag) @upcaster_tag = upcaster_tag end
Protected Instance Methods
populate_defaults()
click to toggle source
@return [undefined]
# File lib/synapse/configuration/component/upcasting/upcaster_chain.rb, line 43 def populate_defaults identified_by :upcaster_chain use_converter_factory :converter_factory use_upcaster_tag :upcaster use_factory do converter_factory = resolve @converter_factory upcaster_chain = Upcasting::UpcasterChain.new converter_factory with_tagged @upcaster_tag do |upcaster| upcaster_chain.push upcaster end upcaster_chain end end