Module: Moleculer::Support::HashUtil
Overview
A module of functional methods for working with hashes
Instance Method Summary collapse
-
#fetch(hash, key, default = :__no_default__) ⇒ Object
Works like fetch, but instead indifferently uses strings and symbols.
Instance Method Details
#fetch(hash, key, default = :__no_default__) ⇒ Object
Works like fetch, but instead indifferently uses strings and symbols. It will try both snake case and camel case versions of the key.
is passed the hash will use an indifferent fetch
20 21 22 23 24 25 |
# File 'lib/moleculer/support/hash_util.rb', line 20 def fetch(hash, key, default = :__no_default__) return fetch_with_string(hash, key, default) if key.is_a?(String) || key.is_a?(Symbol) return hash.fetch(key, default) if default != :__no_default__ hash.fetch(key) end |