Module: Nuggets::Array::HashifyMixin
- Included in:
- Array
- Defined in:
- lib/nuggets/array/hashify_mixin.rb
Instance Method Summary collapse
Instance Method Details
#hashify(value = nil, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/nuggets/array/hashify_mixin.rb', line 31 def hashify(value = nil, &block) block ||= lambda { |key| [key, key] } hash = case value when ::Hash then value when ::Proc then ::Hash.new(&value) else ::Hash.new(value) end each { |key| hash.store(*block[key]) } hash end |