Class: SmartIoC::BeanDefinition
- Inherits:
-
Object
- Object
- SmartIoC::BeanDefinition
- Includes:
- Args
- Defined in:
- lib/smart_ioc/bean_definition.rb
Instance Attribute Summary collapse
-
#after_init ⇒ Object
readonly
Returns the value of attribute after_init.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#factory_method ⇒ Object
readonly
Returns the value of attribute factory_method.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #==(bean_definition) ⇒ Object
- #add_dependency(bean_name:, ref: nil, package: nil) ⇒ Object
- #has_factory_method? ⇒ Boolean
-
#initialize(name:, package:, path:, klass:, scope:, context:, instance:, factory_method:, after_init:) ⇒ BeanDefinition
constructor
A new instance of BeanDefinition.
- #inspect ⇒ Object
- #is_instance? ⇒ Boolean
- #preload ⇒ Object
- #singleton? ⇒ Boolean
Methods included from Args
#check_arg, #check_arg_any, #not_nil
Constructor Details
#initialize(name:, package:, path:, klass:, scope:, context:, instance:, factory_method:, after_init:) ⇒ BeanDefinition
Returns a new instance of BeanDefinition.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 |
Instance Attribute Details
#after_init ⇒ Object (readonly)
Returns the value of attribute after_init.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def after_init @after_init end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def context @context end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def dependencies @dependencies end |
#factory_method ⇒ Object (readonly)
Returns the value of attribute factory_method.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def factory_method @factory_method end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def instance @instance end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def name @name end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def package @package end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def path @path end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/smart_ioc/bean_definition.rb', line 4 def scope @scope end |
Instance Method Details
#==(bean_definition) ⇒ Object
49 50 51 |
# 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) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# 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? ⇒ Boolean
45 46 47 |
# File 'lib/smart_ioc/bean_definition.rb', line 45 def has_factory_method? !@factory_method.nil? end |
#inspect ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# 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? ⇒ Boolean
41 42 43 |
# File 'lib/smart_ioc/bean_definition.rb', line 41 def is_instance? @instance end |
#preload ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/smart_ioc/bean_definition.rb', line 68 def preload @dependencies.each do |dep| bd = SmartIoC.get_bean_definition( dep.ref, package: dep.package, parent_bean_definition: self, parent_bean_name: name, ) bd.preload end end |