Sha256: 4f0e3c284526fbd448cc8c3239591ce851c1c02db981f1d36911baa48d659ccf

Contents?: true

Size: 604 Bytes

Versions: 15

Compression:

Stored size: 604 Bytes

Contents

module Ardm; 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

15 entries across 15 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 lib/ardm/support/ext/array.rb
ardm-0.4.0 lib/ardm/support/ext/array.rb
ardm-0.3.2 lib/ardm/support/ext/array.rb
ardm-0.3.1 lib/ardm/support/ext/array.rb
ardm-0.3.0 lib/ardm/support/ext/array.rb
ardm-0.2.7 lib/ardm/support/ext/array.rb
ardm-0.2.6 lib/ardm/support/ext/array.rb
ardm-0.2.5 lib/ardm/support/ext/array.rb
ardm-0.2.4 lib/ardm/support/ext/array.rb
ardm-0.2.3 lib/ardm/support/ext/array.rb
ardm-0.2.2 lib/ardm/support/ext/array.rb
ardm-0.2.1 lib/ardm/support/ext/array.rb
ardm-0.2.0 lib/ardm/support/ext/array.rb
ardm-0.1.0 lib/ardm/support/ext/array.rb
ardm-0.0.1 lib/ardm/support/ext/array.rb