Sha256: af991f0a94f9a8fae4984d40d0e6c48813ca9a825e28310dfe560129f5175b7b

Contents?: true

Size: 982 Bytes

Versions: 42

Compression:

Stored size: 982 Bytes

Contents

require 'cgi'

module Aws
  # @api private
  module Util
    class << self

      def deep_merge(left, right)
        case left
        when Hash then left.merge(right) { |key, v1, v2| deep_merge(v1, v2) }
        when Array then right + left
        else right
        end
      end

      def copy_hash(hash)
        if Hash === hash
          deep_copy(hash)
        else
          raise ArgumentError, "expected hash, got `#{hash.class}`"
        end
      end

      def deep_copy(obj)
        case obj
        when nil then nil
        when true then true
        when false then false
        when Hash
          obj.inject({}) do |h, (k,v)|
            h[k] = deep_copy(v)
            h
          end
        when Array
          obj.map { |v| deep_copy(v) }
        else
          if obj.respond_to?(:dup)
            obj.dup
          elsif obj.respond_to?(:clone)
            obj.clone
          else
            obj
          end
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
aws-sdk-core-3.32.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.31.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.30.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.29.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.28.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.27.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.27.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.26.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.25.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.24.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.24.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.23.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.22.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.22.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.21.3 lib/aws-sdk-core/util.rb
aws-sdk-core-3.21.2 lib/aws-sdk-core/util.rb
aws-sdk-core-3.21.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.21.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.20.2 lib/aws-sdk-core/util.rb
aws-sdk-core-3.20.1 lib/aws-sdk-core/util.rb