Sha256: 664642b5ca1c34926cbd27f47941394ed1fde774f34407853974f42ce595ad4a

Contents?: true

Size: 610 Bytes

Versions: 11

Compression:

Stored size: 610 Bytes

Contents

module DataMapper; module Ext
  module Array
    # Transforms an Array of key/value pairs into a {Mash}.
    #
    # This is a better idiom than using Mash[*array.flatten] in Ruby 1.8.6
    # because it is not possible to limit the flattening to a single
    # level.
    #
    # @param [Array] array
    #   The array of key/value pairs to transform.
    #
    # @return [Mash]
    #   A {Mash} where each entry in the Array is turned into a key/value.
    #
    # @api semipublic
    def self.to_mash(array)
      m = Mash.new
      array.each { |k,v| m[k] = v }
      m
    end
  end # class Array
end; end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
sbf-dm-core-1.5.0 lib/dm-core/support/ext/array.rb
sbf-dm-core-1.4.0 lib/dm-core/support/ext/array.rb
sbf-dm-core-1.3.0 lib/dm-core/support/ext/array.rb
sbf-dm-core-1.3.0.beta lib/dm-core/support/ext/array.rb
ardm-core-1.3.0 lib/dm-core/support/ext/array.rb
ardm-core-1.2.1 lib/dm-core/support/ext/array.rb
dm-core-1.2.1 lib/dm-core/support/ext/array.rb
ghost_dm-core-1.3.0.beta lib/dm-core/support/ext/array.rb
dm-core-1.2.0 lib/dm-core/support/ext/array.rb
dm-core-1.2.0.rc2 lib/dm-core/support/ext/array.rb
dm-core-1.2.0.rc1 lib/dm-core/support/ext/array.rb