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, &procedure) ⇒ ComponentInfoDef

  • args

    1. Hash options

    2. Proc procedure



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

def initialize(options, &procedure)
  @component_class = options[:class]
  @component_name  =  options[:name]
  @instance    = options[:instance]
  @autobinding = options[:autobinding]
  @namespace   = options[:namespace]
  @procedure   = procedure
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

#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



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

def namespace
  @namespace
end

#procedureObject

Returns the value of attribute procedure.



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

def procedure
  @procedure
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

#==(other) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/seasar/container/component-info-def.rb', line 107

def ==(other)
  @component_class == other.component_class &&
  @component_name  == other.component_name &&
  @instance == other.instance &&
  @autobinding == other.autobinding &&
  self.namespace() == other.namespace() &&
  @procedure == other.procedure
end

#[](key) ⇒ Object

  • args

    1. Symbol key

  • return

    • Object



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

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

#match(matcher) ⇒ Object

  • args

    1. Objectn matcher

  • return

    • Boolean



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/seasar/container/component-info-def.rb', line 85

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