class IocRb::BeanMetadata
Stores bean specific data: bean class, name, scope and bean dependencies
Attributes
attrs[R]
bean_class[R]
factory_method[R]
instance[R]
name[R]
scope[R]
Public Class Methods
new(name, options, &block)
click to toggle source
Constructor @param name [Symbol] bean name @params options [Hash] includes bean class and scope @params &block [Proc] bean dependencies, has the following structure:
do |c| attr :some_dependency, ref: :dependency_name arg :another_dependency, ref: :another_dependency_name end
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
# File lib/ioc_rb/bean_metadata.rb, line 17 def initialize(name, options, &block) IocRb::ArgsValidator.has_key!(options, :class) @name = name @bean_class = options[:class] @scope = options[:scope] || :singleton @instance = options[:instance].nil? ? true : options[:instance] @factory_method = options[:factory_method] @attrs = [] fetch_attrs!(@bean_class) if block Dsl.new(@attrs).instance_exec(&block) end end
Public Instance Methods
fetch_attrs!(klass)
click to toggle source
# 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, options| options[:ref] ||= attr @attrs << IocRb::BeanMetadata::Attribute.new(attr, options) end end end
has_factory_method?()
click to toggle source
# File lib/ioc_rb/bean_metadata.rb, line 43 def has_factory_method? !!@factory_method end