Class: Macmillan::Utils::Settings::Lookup

Inherits:
Object
  • Object
show all
Defined in:
lib/macmillan/utils/settings/lookup.rb

Instance Method Summary collapse

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

Raises:



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