class SmartIoC::BeanDefinition

Attributes

after_init[R]
context[R]
dependencies[R]
factory_method[R]
instance[R]
klass[R]
name[R]
package[R]
path[R]
scope[R]

Public Class Methods

new(name:, package:, path:, klass:, scope:, context:, instance:, factory_method:, after_init:) click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 7
def initialize(name:, package:, path:, klass:, scope:, context:, instance:, factory_method:, after_init:)
  not_nil(name, :name)
  not_nil(package, :package)
  not_nil(path, :path)
  not_nil(klass, :klass)
  not_nil(scope, :scope)
  not_nil(context, :context)
  not_nil(instance, :instance)

  @name           = name
  @package        = package
  @path           = path
  @klass          = klass
  @scope          = scope
  @instance       = instance
  @factory_method = factory_method
  @after_init     = after_init
  @context        = context

  @dependencies = []
end

Public Instance Methods

==(bean_definition) click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 49
def ==(bean_definition)
  bean_definition.name == @name && bean_definition.package == @package && bean_definition.context == @context
end
add_dependency(bean_name:, ref: nil, package: nil) click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 29
def add_dependency(bean_name:, ref: nil, package: nil)
  check_arg(bean_name, :bean_name, Symbol)
  check_arg(ref, :ref, Symbol) if ref
  check_arg(package, :package, Symbol) if package

  @dependencies << SmartIoC::BeanDependency.new(
    bean:    bean_name,
    ref:     ref,
    package: package
  )
end
has_factory_method?() click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 45
def has_factory_method?
  !@factory_method.nil?
end
inspect() click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 57
def inspect
  str = []
  str << "name:           :#{@name}"
  str << "package:        :#{@package}"
  str << "context:        :#{@context}"
  str << "path:           #{@path}"
  str << "instance:       #{@instance}"
  str << "factory_method: #{@factory_method}"
  str.join("\n")
end
is_instance?() click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 41
def is_instance?
  @instance
end
singleton?() click to toggle source
# File lib/smart_ioc/bean_definition.rb, line 53
def singleton?
  SmartIoC::Scopes::Singleton::VALUE == @scope
end