Class: Observed::Hash::Fetcher

Inherits:
Object
  • Object
show all
Includes:
KeyPathEncoding
Defined in:
lib/observed/hash/fetcher.rb

Instance Method Summary collapse

Methods included from KeyPathEncoding

#at_key_path_on_hash

Constructor Details

#initialize(hash) ⇒ Fetcher

Returns a new instance of Fetcher.



8
9
10
# File 'lib/observed/hash/fetcher.rb', line 8

def initialize(hash)
  @hash = hash || fail('The hash must not be nil')
end

Instance Method Details

#[](key_path) ⇒ Object



12
13
14
15
16
# File 'lib/observed/hash/fetcher.rb', line 12

def [](key_path)
  at_key_path_on_hash @hash, key_path, create_if_missing: false do |h, k|
    h[k]
  end
end