Sha256: a5eb4eb25cd32bcc57a0188fa0e7137ceadfa7225513d446cf3dc20ffa31e0cc

Contents?: true

Size: 557 Bytes

Versions: 15

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

module Grape
  module Extensions
    class DeepMergeableHash < ::Hash
      def deep_merge!(other_hash)
        other_hash.each_pair do |current_key, other_value|
          this_value = self[current_key]

          self[current_key] = if this_value.is_a?(::Hash) && other_value.is_a?(::Hash)
                                this_value.deep_merge(other_value)
                              else
                                other_value
                              end
        end

        self
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
grape-1.7.1 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.7.0 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.6.2 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.6.1 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.6.0 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.5.3 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.5.2 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.5.1 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.5.0 lib/grape/extensions/deep_mergeable_hash.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/lib/grape/extensions/deep_mergeable_hash.rb
grape-1.4.0 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.3.3 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.3.2 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.3.1 lib/grape/extensions/deep_mergeable_hash.rb
grape-1.3.0 lib/grape/extensions/deep_mergeable_hash.rb