Sha256: 95d0f5f524a74aeab88f380feaf7f31594619c2d4d1ebce9fc15d7645afd4870

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

module ApiValidator
  module Mixins

    module DeepMerge
      def deep_merge!(hash, *others)
        others.each do |other|
          other.each_pair do |key, val|
            if hash.has_key?(key)
              next if hash[key] == val
              case val
              when Hash
                deep_merge!(hash[key], val)
              when Array
                hash[key].concat(val)
              when FalseClass
                # false always wins
                hash[key] = val
              end
            else
              hash[key] = val
            end
          end
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
api-validator-0.0.1 lib/api-validator/mixins/deep_merge.rb