Class: Objectify::Config::Injectables

Inherits:
Object
  • Object
show all
Defined in:
lib/objectify/config/injectables.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/objectify/config/injectables.rb', line 4

def config
  @config
end

#contextObject



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