Sha256: dc778e8a1410df61fb61343b17fcf68a7ec31e477c1f16e9d00fb2ba75a60fca

Contents?: true

Size: 611 Bytes

Versions: 16

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

module WebMock
  module Util
    class HashKeysStringifier

      def self.stringify_keys!(arg, options = {})
        case arg
        when Array
          arg.map { |elem|
            options[:deep] ? stringify_keys!(elem, options) : elem
          }
        when Hash
          Hash[
            *arg.map { |key, value|
              k = key.is_a?(Symbol) ? key.to_s : key
              v = (options[:deep] ? stringify_keys!(value, options) : value)
              [k,v]
            }.inject([]) {|r,x| r + x}]
        else
          arg
        end
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 5 rubygems

Version Path
webmock-3.25.1 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.25.0 lib/webmock/util/hash_keys_stringifier.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/webmock-3.24.0/lib/webmock/util/hash_keys_stringifier.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/webmock-3.23.1/lib/webmock/util/hash_keys_stringifier.rb
webmock-3.24.0 lib/webmock/util/hash_keys_stringifier.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/webmock-3.23.1/lib/webmock/util/hash_keys_stringifier.rb
webmock-3.23.0 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.22.0 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.21.2 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.21.1 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.21.0 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.20.0 lib/webmock/util/hash_keys_stringifier.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/webmock-3.19.1/lib/webmock/util/hash_keys_stringifier.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/webmock-3.19.1/lib/webmock/util/hash_keys_stringifier.rb
webmock-3.19.1 lib/webmock/util/hash_keys_stringifier.rb
webmock-3.19.0 lib/webmock/util/hash_keys_stringifier.rb