Class: IocRb::BeanMetadata
Overview
Stores bean specific data: bean class, name, scope and bean dependencies
Defined Under Namespace
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#bean_class ⇒ Object
readonly
Returns the value of attribute bean_class.
-
#factory_method ⇒ Object
readonly
Returns the value of attribute factory_method.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #fetch_attrs!(klass) ⇒ Object
- #has_factory_method? ⇒ Boolean
-
#initialize(name, options, &block) ⇒ BeanMetadata
constructor
Constructor here attr means setter injection, arg means constructon injects
some_dependency
is an attr_accessor defined in the bean class,ref
specifies what dependency from container to use to set the attribute.
Constructor Details
#initialize(name, options, &block) ⇒ BeanMetadata
Constructor here attr means setter injection, arg means constructon injects some_dependency
is an attr_accessor defined in the bean class, ref
specifies what dependency from container to use to set the attribute
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ioc_rb/bean_metadata.rb', line 17 def initialize(name, , &block) IocRb::ArgsValidator.has_key!(, :class) @name = name @bean_class = [:class] @scope = [:scope] || :singleton @instance = [:instance].nil? ? true : [:instance] @factory_method = [:factory_method] @attrs = [] fetch_attrs!(@bean_class) if block Dsl.new(@attrs).instance_exec(&block) end end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
4 5 6 |
# File 'lib/ioc_rb/bean_metadata.rb', line 4 def attrs @attrs end |
#bean_class ⇒ Object (readonly)
Returns the value of attribute bean_class.
4 5 6 |
# File 'lib/ioc_rb/bean_metadata.rb', line 4 def bean_class @bean_class end |
#factory_method ⇒ Object (readonly)
Returns the value of attribute factory_method.
4 5 6 |
# File 'lib/ioc_rb/bean_metadata.rb', line 4 def factory_method @factory_method end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
4 5 6 |
# File 'lib/ioc_rb/bean_metadata.rb', line 4 def instance @instance end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/ioc_rb/bean_metadata.rb', line 4 def name @name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/ioc_rb/bean_metadata.rb', line 4 def scope @scope end |
Instance Method Details
#fetch_attrs!(klass) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/ioc_rb/bean_metadata.rb', line 34 def fetch_attrs!(klass) if klass.respond_to?(:_iocrb_injectable_attrs) klass._iocrb_injectable_attrs.each do |attr, | [:ref] ||= attr @attrs << IocRb::BeanMetadata::Attribute.new(attr, ) end end end |
#has_factory_method? ⇒ Boolean
43 44 45 |
# File 'lib/ioc_rb/bean_metadata.rb', line 43 def has_factory_method? !!@factory_method end |