Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/tlspretense/ext_core/hash_indifferent_fetch.rb
Instance Method Summary collapse
-
#indifferent_fetch(key, *extra) ⇒ Object
Light extension to hash to add indifferent fetching.
Instance Method Details
#indifferent_fetch(key, *extra) ⇒ Object
Light extension to hash to add indifferent fetching. Meant to be more lightweight than depending on ActiveSupport for HashWithIndifferentAccess.
5 6 7 8 9 10 11 |
# File 'lib/tlspretense/ext_core/hash_indifferent_fetch.rb', line 5 def indifferent_fetch(key, *extra) if key.class == Symbol self.fetch(key, self.fetch(key.to_s, *extra)) else self.fetch(key, self.fetch(key.to_sym, *extra)) end end |