Class: DependencyInjection::Definition
- Inherits:
-
Object
- Object
- DependencyInjection::Definition
- Defined in:
- lib/dependency_injection/definition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#configurator ⇒ Object
Returns the value of attribute configurator.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#klass_name ⇒ Object
Returns the value of attribute klass_name.
-
#method_calls ⇒ Object
Returns the value of attribute method_calls.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #add_argument(argument) ⇒ Object
- #add_arguments(*arguments) ⇒ Object
- #add_configurator(name, method_name) ⇒ Object
- #add_method_call(method_name, *arguments) ⇒ Object
-
#initialize(klass_name, container) ⇒ Definition
constructor
A new instance of Definition.
- #klass ⇒ Object
- #object ⇒ Object
Constructor Details
#initialize(klass_name, container) ⇒ Definition
Returns a new instance of Definition.
8 9 10 11 12 13 14 15 |
# File 'lib/dependency_injection/definition.rb', line 8 def initialize(klass_name, container) @container = container self.arguments = [] self.file_path = nil self.klass_name = klass_name self.method_calls = {} self.scope = :container end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
6 7 8 |
# File 'lib/dependency_injection/definition.rb', line 6 def arguments @arguments end |
#configurator ⇒ Object
Returns the value of attribute configurator.
6 7 8 |
# File 'lib/dependency_injection/definition.rb', line 6 def configurator @configurator end |
#file_path ⇒ Object
Returns the value of attribute file_path.
6 7 8 |
# File 'lib/dependency_injection/definition.rb', line 6 def file_path @file_path end |
#klass_name ⇒ Object
Returns the value of attribute klass_name.
6 7 8 |
# File 'lib/dependency_injection/definition.rb', line 6 def klass_name @klass_name end |
#method_calls ⇒ Object
Returns the value of attribute method_calls.
6 7 8 |
# File 'lib/dependency_injection/definition.rb', line 6 def method_calls @method_calls end |
#scope ⇒ Object
Returns the value of attribute scope.
6 7 8 |
# File 'lib/dependency_injection/definition.rb', line 6 def scope @scope end |
Instance Method Details
#add_argument(argument) ⇒ Object
17 18 19 |
# File 'lib/dependency_injection/definition.rb', line 17 def add_argument(argument) self.add_arguments(argument) end |
#add_arguments(*arguments) ⇒ Object
21 22 23 24 25 |
# File 'lib/dependency_injection/definition.rb', line 21 def add_arguments(*arguments) self.arguments += arguments self end |
#add_configurator(name, method_name) ⇒ Object
27 28 29 30 31 |
# File 'lib/dependency_injection/definition.rb', line 27 def add_configurator(name, method_name) self.configurator = [name, method_name] self end |
#add_method_call(method_name, *arguments) ⇒ Object
33 34 35 36 37 |
# File 'lib/dependency_injection/definition.rb', line 33 def add_method_call(method_name, *arguments) self.method_calls[method_name] = arguments self end |
#klass ⇒ Object
39 40 41 |
# File 'lib/dependency_injection/definition.rb', line 39 def klass self.klass_name.constantize end |
#object ⇒ Object
43 44 45 |
# File 'lib/dependency_injection/definition.rb', line 43 def object self.send("#{self.scope}_scoped_object") end |