Sha256: 4f30a3dfa5492faaf9f24ab5d4549294c4d575d652d50339269718da1632ce1c

Contents?: true

Size: 1.34 KB

Versions: 77

Compression:

Stored size: 1.34 KB

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

      def monotonic_milliseconds
        if defined?(Process::CLOCK_MONOTONIC)
          Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
        else
          DateTime.now.strftime('%Q').to_i
        end
      end

      def str_2_bool(str)
        case str.to_s
        when "true" then true
        when "false" then false
        else
          nil
        end
      end

    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
aws-sdk-core-3.90.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.90.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.89.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.89.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.88.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.87.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.86.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.85.1 lib/aws-sdk-core/util.rb
aws-sdk-core-3.85.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.84.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.83.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.82.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.81.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.80.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.79.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.78.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.77.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.76.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.75.0 lib/aws-sdk-core/util.rb
aws-sdk-core-3.74.0 lib/aws-sdk-core/util.rb