Class: Macmillan::Utils::Settings::Lookup
- Inherits:
-
Object
- Object
- Macmillan::Utils::Settings::Lookup
- Defined in:
- lib/macmillan/utils/settings/lookup.rb
Instance Method Summary collapse
-
#initialize(backends) ⇒ Lookup
constructor
A new instance of Lookup.
- #lookup(key) ⇒ Object (also: #[], #fetch)
Constructor Details
#initialize(backends) ⇒ Lookup
Returns a new instance of Lookup.
5 6 7 |
# File 'lib/macmillan/utils/settings/lookup.rb', line 5 def initialize(backends) @backends = backends end |
Instance Method Details
#lookup(key) ⇒ Object Also known as: [], fetch
9 10 11 12 13 14 15 16 |
# File 'lib/macmillan/utils/settings/lookup.rb', line 9 def lookup(key) @backends.each do |backend| result = backend.get(key) return result.value unless result.is_a?(KeyNotFound) end raise KeyNotFoundError.new("Cannot find a settings value for #{key}") end |