Class: MidwireCommon::BottomlessHash
- Inherits:
-
Hash
- Object
- Hash
- MidwireCommon::BottomlessHash
- Defined in:
- lib/midwire_common/hash.rb
Overview
By Nick Ostrovsky firedev.com/posts/2015/bottomless-ruby-hash/
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ BottomlessHash
constructor
A new instance of BottomlessHash.
Constructor Details
#initialize ⇒ BottomlessHash
Returns a new instance of BottomlessHash.
13 14 15 |
# File 'lib/midwire_common/hash.rb', line 13 def initialize super(&->(hash, key) { hash[key] = self.class.new }) end |
Class Method Details
.from_hash(hash) ⇒ Object
9 10 11 |
# File 'lib/midwire_common/hash.rb', line 9 def self.from_hash(hash) new.merge(hash) end |