Class: Moltrio::Config::AdapterChain
- Inherits:
-
Adapter
- Object
- Adapter
- Moltrio::Config::AdapterChain
show all
- Defined in:
- lib/moltrio/config/adapter_chain.rb
Instance Method Summary
collapse
Methods inherited from Adapter
#fetch, #fetch_all, #slice
Constructor Details
Returns a new instance of AdapterChain.
7
8
9
|
# File 'lib/moltrio/config/adapter_chain.rb', line 7
def initialize(adapters)
@adapters = Hamster.list(*adapters)
end
|
Instance Method Details
#[](key) ⇒ Object
19
20
21
22
23
|
# File 'lib/moltrio/config/adapter_chain.rb', line 19
def [](key)
if adapter = adapter_for_key(key)
adapter[key]
end
end
|
#[]=(key, value) ⇒ Object
25
26
27
|
# File 'lib/moltrio/config/adapter_chain.rb', line 25
def []=(key, value)
first_adapter[key] = value
end
|
#available_namespaces ⇒ Object
37
38
39
40
41
|
# File 'lib/moltrio/config/adapter_chain.rb', line 37
def available_namespaces
adapters.reduce(Hamster.set) { |set, adapter|
set.merge(adapter.available_namespaces)
}
end
|
#has_key?(key) ⇒ Boolean
29
30
31
|
# File 'lib/moltrio/config/adapter_chain.rb', line 29
def has_key?(key)
!!adapter_for_key(key)
end
|
#missing_namespace? ⇒ Boolean
33
34
35
|
# File 'lib/moltrio/config/adapter_chain.rb', line 33
def missing_namespace?
adapters.any?(&:missing_namespace?)
end
|
#on_namespace(namespace) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/moltrio/config/adapter_chain.rb', line 11
def on_namespace(namespace)
adapters_on_namespace = adapters.map { |adapter|
adapter.on_namespace(namespace)
}
self.class.new(adapters_on_namespace)
end
|