Class: BareHash
Overview
Creates a new class, BareHash, that is alike a Hash in every way except that it may be accessed by a symbol or a string for every key. Really the same thing as HashWithIndifferentAccess but without ActiveSupport
Instance Method Summary collapse
Methods inherited from Hash
Instance Method Details
#[](key) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/silver/cache.rb', line 9 def [](key) if self.include? key self.fetch(key) else key.class == String ? self.fetch(key.to_sym,nil) : self.fetch(key.to_s, nil) end end |