Class: Objectify::Config::Injectables
- Inherits:
-
Object
- Object
- Objectify::Config::Injectables
- Defined in:
- lib/objectify/config/injectables.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
- #context ⇒ Object
Instance Method Summary collapse
- #add_decorators(name, value) ⇒ Object
- #add_implementation(name, value) ⇒ Object
- #add_resolver(name, value) ⇒ Object
- #add_value(name, value) ⇒ Object
- #decorators(name) ⇒ Object
- #get(name) ⇒ Object
-
#initialize(config = {}) ⇒ Injectables
constructor
A new instance of Injectables.
- #merge(other) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Injectables
Returns a new instance of Injectables.
7 8 9 10 |
# File 'lib/objectify/config/injectables.rb', line 7 def initialize(config = {}) @config = config @decorators = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/objectify/config/injectables.rb', line 4 def config @config end |
#context ⇒ Object
36 37 38 |
# File 'lib/objectify/config/injectables.rb', line 36 def context @context && @context.config || {} end |
Instance Method Details
#add_decorators(name, value) ⇒ Object
28 29 30 |
# File 'lib/objectify/config/injectables.rb', line 28 def add_decorators(name, value) @decorators[name] = value end |
#add_implementation(name, value) ⇒ Object
20 21 22 |
# File 'lib/objectify/config/injectables.rb', line 20 def add_implementation(name, value) @config[name] = [:implementation, value] end |
#add_resolver(name, value) ⇒ Object
12 13 14 |
# File 'lib/objectify/config/injectables.rb', line 12 def add_resolver(name, value) @config[name] = [:resolver, value] end |
#add_value(name, value) ⇒ Object
16 17 18 |
# File 'lib/objectify/config/injectables.rb', line 16 def add_value(name, value) @config[name] = [:value, value] end |
#decorators(name) ⇒ Object
32 33 34 |
# File 'lib/objectify/config/injectables.rb', line 32 def decorators(name) [*@decorators[name]].compact end |
#get(name) ⇒ Object
24 25 26 |
# File 'lib/objectify/config/injectables.rb', line 24 def get(name) @config[name] || context[name] || [:unknown, name] end |
#merge(other) ⇒ Object
40 41 42 |
# File 'lib/objectify/config/injectables.rb', line 40 def merge(other) self.class.new @config.merge(other.config) end |