Class: Copland::Configuration::YAML::ImplementorProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/copland/configuration/yaml/implementor.rb

Overview

This delegate is responsible for processing the ‘implementor’ token in a YAML stream.

Instance Method Summary collapse

Instance Method Details

#process(point, definition) ⇒ Object

Process the given implementor definition and set the service point’s instantiator to the resulting instantiator.

If definition is a string, then the instantiator will be “simple”, backed by the class given as the definition.

If definition is a Hash, then the instantiator will be “complex”, and will be described by the definition.

Any other type is an error.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/copland/configuration/yaml/implementor.rb', line 62

def process( point, definition )
  case definition
    when String
      instantiator = "simple"
    when Hash
      instantiator = "complex"
      deyamlize_hash point, definition
    else
      raise ParserError,
        "'implementor' must be either a String or a Hash"
  end

  factory = Copland::ClassFactory.instance
  point.instantiator = factory.get( Copland::Instantiator::POOL_NAME,
    instantiator, point, definition )
end