Class: Seasar::Container::Assembler::AbstractAssembler

Inherits:
Object
  • Object
show all
Defined in:
lib/seasar/container/assembler/abstract-assembler.rb

Overview

コンポーネントを構築する(アセンブルする)抽象クラスです。

Instance Method Summary collapse

Constructor Details

#initialize(component_def) ⇒ AbstractAssembler

AbstractAssemblerを構築します。

  • args

    1. Seasar::Container::ComponentDefSymbol component_def



29
30
31
# File 'lib/seasar/container/assembler/abstract-assembler.rb', line 29

def initialize(component_def)
  @component_def = component_def
end

Instance Method Details

#get_argument(component_key, is_array_acceptable = False) ⇒ Object

AutoConstructorAssemblerとAutoPropertyAssemblerでタイプヒントされたコンポーネントを取得する際に

呼び出される。
@param string component_key
@param boolean is_array_acceptable
@return mixed
  • args

    1. String|Symbol component_key

    2. Boolean is_array_acceptable

  • return

    • Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/seasar/container/assembler/abstract-assembler.rb', line 45

def get_argument(component_key, is_array_acceptable = False)
  value = nil
  begin
    s2logger.fatal(self){ 'aaa ' + component_key.to_s}
    value = @component_def.container.get_component(component_key)
  rescue Seasar::Container::Exception::TooManyRegistrationRuntimeException => e
    if is_array_acceptable
      child_component_defs = @component_def.container.get_component_def(component_key).component_defs
      value = []
      for child_component_def in child_component_defs
        value << child_component_def.component
      end
    else
      raise e
    end
  rescue Seasar::Container::Exception::ComponentNotFoundRuntimeException => e
    s2logger.debug(self.class.name) {"no component found for key #{component_key}"}
  end
  return value
end