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_implementation(name, value) ⇒ Object
- #add_resolver(name, value) ⇒ Object
- #add_value(name, value) ⇒ 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 |
# File 'lib/objectify/config/injectables.rb', line 7 def initialize(config = {}) @config = config 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
27 28 29 |
# File 'lib/objectify/config/injectables.rb', line 27 def context @context && @context.config || {} end |
Instance Method Details
#add_implementation(name, value) ⇒ Object
19 20 21 |
# File 'lib/objectify/config/injectables.rb', line 19 def add_implementation(name, value) @config[name] = [:implementation, value] end |
#add_resolver(name, value) ⇒ Object
11 12 13 |
# File 'lib/objectify/config/injectables.rb', line 11 def add_resolver(name, value) @config[name] = [:resolver, value] end |
#add_value(name, value) ⇒ Object
15 16 17 |
# File 'lib/objectify/config/injectables.rb', line 15 def add_value(name, value) @config[name] = [:value, value] end |
#get(name) ⇒ Object
23 24 25 |
# File 'lib/objectify/config/injectables.rb', line 23 def get(name) @config[name] || context[name] || [:unknown, name] end |
#merge(other) ⇒ Object
31 32 33 |
# File 'lib/objectify/config/injectables.rb', line 31 def merge(other) self.class.new @config.merge(other.config) end |