Method: Arcanus::Chest#get

Defined in:
lib/arcanus/chest.rb

#get(key_path) ⇒ Object

Get value at the specified key path.

Parameters:

  • key_path (String)

Returns:

  • (Object)


88
89
90
91
92
93
94
# File 'lib/arcanus/chest.rb', line 88

def get(key_path)
  keys = key_path.split('.')
  keys.inject(@hash) { |hash, key| hash[key] }
rescue NoMethodError
  raise Arcanus::Errors::InvalidKeyPathError,
        "Key path '#{key_path}' does not correspond to an actual key"
end