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 ⇒ Object
readonly
Returns the value of attribute id.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#kwargs ⇒ Object
readonly
Returns the value of attribute kwargs.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #anonymous? ⇒ Boolean
-
#build(injector) ⇒ Object
# @return [Object].
-
#initialize(klass, args: [], kwargs: {}, calls: [], tags: [], id: nil, anonymous: false) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(klass, args: [], kwargs: {}, calls: [], tags: [], id: nil, anonymous: false) ⇒ Definition
Returns a new instance of Definition.
15 16 17 18 19 20 21 22 23 |
# File 'lib/corindon/dependency_injection/definition.rb', line 15 def initialize(klass, args: [], kwargs: {}, calls: [], tags: [], id: nil, anonymous: false) @klass = klass @args = args @kwargs = kwargs @calls = calls @tags = @id = id @anonymous = anonymous 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 ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/corindon/dependency_injection/definition.rb', line 13 def id @id end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
8 9 10 |
# File 'lib/corindon/dependency_injection/definition.rb', line 8 def klass @klass 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 |
#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
#anonymous? ⇒ Boolean
38 39 40 |
# File 'lib/corindon/dependency_injection/definition.rb', line 38 def anonymous? @anonymous end |
#build(injector) ⇒ Object
# @return [Object]
27 28 29 30 31 32 33 34 35 |
# File 'lib/corindon/dependency_injection/definition.rb', line 27 def build(injector) object = do_call(klass, :new, injector.resolve(args), injector.resolve(kwargs)) calls.each do |(call, call_args, call_kwargs)| do_call(object, call, injector.resolve(call_args), injector.resolve(call_kwargs)) end object end |