Class: Corindon::DependencyInjection::Definition
- Inherits:
-
Object
- Object
- Corindon::DependencyInjection::Definition
- Defined in:
- lib/corindon/dependency_injection/definition.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
- #id ⇒ String readonly
-
#kwargs ⇒ Object
readonly
Returns the value of attribute kwargs.
-
#object_source ⇒ Object
readonly
Returns the value of attribute object_source.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #build(injector) ⇒ Object
-
#initialize(object_source, args: [], kwargs: {}, calls: [], tags: [], id: nil) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(object_source, args: [], kwargs: {}, calls: [], tags: [], id: nil) ⇒ Definition
Returns a new instance of Definition.
16 17 18 19 20 21 22 23 |
# File 'lib/corindon/dependency_injection/definition.rb', line 16 def initialize(object_source, args: [], kwargs: {}, calls: [], tags: [], id: nil) @object_source = object_source @args = args @kwargs = kwargs @calls = calls @tags = @id = id end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/corindon/dependency_injection/definition.rb', line 9 def args @args end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
11 12 13 |
# File 'lib/corindon/dependency_injection/definition.rb', line 11 def calls @calls end |
#id ⇒ String (readonly)
14 15 16 |
# File 'lib/corindon/dependency_injection/definition.rb', line 14 def id @id end |
#kwargs ⇒ Object (readonly)
Returns the value of attribute kwargs.
10 11 12 |
# File 'lib/corindon/dependency_injection/definition.rb', line 10 def kwargs @kwargs end |
#object_source ⇒ Object (readonly)
Returns the value of attribute object_source.
8 9 10 |
# File 'lib/corindon/dependency_injection/definition.rb', line 8 def object_source @object_source end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
12 13 14 |
# File 'lib/corindon/dependency_injection/definition.rb', line 12 def @tags end |
Instance Method Details
#build(injector) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/corindon/dependency_injection/definition.rb', line 27 def build(injector) source = if object_source.is_a?(Class) [object_source, :new] else injector.resolve(object_source) end object = RubyCompat.do_call(*source, injector.resolve(args), injector.resolve(kwargs)) calls.each do |(call, call_args, call_kwargs)| RubyCompat.do_call(object, call, injector.resolve(call_args), injector.resolve(call_kwargs)) end object end |