Sha256: 4bda8fc195e1eeffe993a07b1cae4a6d19a75ecf8190b331cde2514ef6ceb4ab

Contents?: true

Size: 610 Bytes

Versions: 5

Compression:

Stored size: 610 Bytes

Contents

module MightyGrid
  module MgHash
    class << self
    	# A deep merge of two hashes.
      # That is, if both hashes have the same key and the values are hashes, these two hashes should also be merged.
      # Used for merging two sets of params.
      def rec_merge(hash, other)  #:nodoc:
        res = hash.clone
        other.each do |key, other_value|
          value = res[key]
          if value.is_a?(Hash) && other_value.is_a?(Hash)
            res[key] = rec_merge value, other_value
          else
            res[key] = other_value
          end
        end
        res
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mighty_grid-0.1.0 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.0.6 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.0.5 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.0.4 lib/mighty_grid/mighty_grid_ext.rb
mighty_grid-0.0.3 lib/mighty_grid/mighty_grid_ext.rb