class Synapse::Configuration::ConverterFactoryDefinitionBuilder

Definition builder used to create a converter factory

@example The minimum possible effort to build a converter factory

converter_factory

@example Create a converter factory using a different identifier and different converter tag

converter_factory :alt_converter_factory do
  use_converter_tag :alt_converter
end

@example Register several converters that will be picked up by a converter factory

factory :xml2ox_converter, :tag => :converter do
  Serialization::XmlToOxDocumentConverter.new
end

factory :ox2xml_converter, :tag => :converter do
  Serialization::OxDocumentToXmlConverter.new
end

Public Instance Methods

use_converter_tag(converter_tag) click to toggle source

Changes the tag to use to automatically register converters

@see Serialization::Converter @param [Symbol] converter_tag @return [undefined]

# File lib/synapse/configuration/component/serialization/converter_factory.rb, line 27
def use_converter_tag(converter_tag)
  @converter_tag = converter_tag
end

Protected Instance Methods

populate_defaults() click to toggle source

@return [undefined]

# File lib/synapse/configuration/component/serialization/converter_factory.rb, line 34
def populate_defaults
  identified_by :converter_factory

  use_converter_tag :converter

  use_factory do
    converter_factory = Serialization::ConverterFactory.new

    with_tagged @converter_tag do |converter|
      converter_factory.register converter
    end

    converter_factory
  end
end