Class: Seasar::Container::ComponentInfoDef

Inherits:
Object
  • Object
show all
Defined in:
lib/seasar/container/component-info-def.rb

Constant Summary collapse

@@auto_namespace =
false

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ ComponentInfoDef

  • args

    1. Hash options

    2. Proc block



45
46
47
48
49
50
51
52
# File 'lib/seasar/container/component-info-def.rb', line 45

def initialize(options, &block)
  @component_class = options[:class]
  @component_name  =  options[:name]
  @instance    = options[:instance]
  @autobinding = options[:autobinding]
  @namespace   = options[:namespace]
  @constructor   = block
end

Instance Attribute Details

#autobindingObject

Returns the value of attribute autobinding.



53
54
55
# File 'lib/seasar/container/component-info-def.rb', line 53

def autobinding
  @autobinding
end

#component_classObject

Returns the value of attribute component_class.



53
54
55
# File 'lib/seasar/container/component-info-def.rb', line 53

def component_class
  @component_class
end

#component_nameObject

Returns the value of attribute component_name.



53
54
55
# File 'lib/seasar/container/component-info-def.rb', line 53

def component_name
  @component_name
end

#constructor(&block) ⇒ Object

  • args

    1. Proc|nil block

  • return

    • Proc



62
63
64
# File 'lib/seasar/container/component-info-def.rb', line 62

def constructor
  @constructor
end

#destructor(&block) ⇒ Object

  • args

    1. Proc|nil block

  • return

    • Proc



75
76
77
# File 'lib/seasar/container/component-info-def.rb', line 75

def destructor
  @destructor
end

#instanceObject

Returns the value of attribute instance.



53
54
55
# File 'lib/seasar/container/component-info-def.rb', line 53

def instance
  @instance
end

#namespaceObject

  • args

    • none

  • return

    • String



88
89
90
# File 'lib/seasar/container/component-info-def.rb', line 88

def namespace
  @namespace
end

Class Method Details

.auto_namespaceObject

  • args

    • none

  • return

    • Boolean



39
# File 'lib/seasar/container/component-info-def.rb', line 39

def auto_namespace; return @@auto_namespace; end

.auto_namespace=(val) ⇒ Object

  • args

    1. Boolean val

  • return

    • none



31
# File 'lib/seasar/container/component-info-def.rb', line 31

def auto_namespace=(val); @@auto_namespace = val; end

Instance Method Details

#[](key) ⇒ Object

  • args

    1. Symbol key

  • return

    • Object



102
103
104
# File 'lib/seasar/container/component-info-def.rb', line 102

def [](key)
  return self.instance_variable_get(key)
end

#match(matcher) ⇒ Object

  • args

    1. Objectn matcher

  • return

    • Boolean



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/seasar/container/component-info-def.rb', line 112

def match(matcher)
  case
  when matcher.is_a?(Regexp)
    if @component_name.is_a?(String)
      if matcher.match(@component_name)
        return true
      end
    end
    return matcher.match(@component_class.name)
  when matcher.is_a?(Class)
    return @component_class == matcher
  when matcher.is_a?(Module)
    return @component_class.name.match(/^#{matcher.name}::/)
  when matcher.is_a?(String)
    return (matcher == @component_name or matcher == @component_class.name)
  when matcher.is_a?(Symbol)
    return (matcher == @component_name or matcher == @component_class.name.to_sym)
  else
    raise ArgumentError.new("unsupported argument #{matcher}")
  end
end