Module: DataMapper::Ext::Array
- Defined in:
- lib/dm-core/support/ext/array.rb
Class Method Summary collapse
-
.to_hash(array) ⇒ Hash
Transforms an Array of key/value pairs into a Hash.
-
.to_mash(array) ⇒ Mash
Transforms an Array of key/value pairs into a Mash.
Class Method Details
.to_hash(array) ⇒ Hash
Transforms an Array of key/value pairs into a Hash.
This is a better idiom than using Hash in Ruby 1.8.6 because it is not possible to limit the flattening to a single level.
16 17 18 19 20 |
# File 'lib/dm-core/support/ext/array.rb', line 16 def self.to_hash(array) h = {} array.each { |k,v| h[k] = v } h end |