Sha256: 2125c7d749de10fdc7b80103031137b2f6718ca53de20f6028ac3b1ad8f80d23

Contents?: true

Size: 1.11 KB

Versions: 141

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Faraday
  module Utils
    # A hash with stringified keys.
    class ParamsHash < Hash
      def [](key)
        super(convert_key(key))
      end

      def []=(key, value)
        super(convert_key(key), value)
      end

      def delete(key)
        super(convert_key(key))
      end

      def include?(key)
        super(convert_key(key))
      end

      alias has_key? include?
      alias member? include?
      alias key? include?

      def update(params)
        params.each do |key, value|
          self[key] = value
        end
        self
      end
      alias merge! update

      def merge(params)
        dup.update(params)
      end

      def replace(other)
        clear
        update(other)
      end

      def merge_query(query, encoder = nil)
        return self unless query && !query.empty?

        update((encoder || Utils.default_params_encoder).decode(query))
      end

      def to_query(encoder = nil)
        (encoder || Utils.default_params_encoder).encode(self)
      end

      private

      def convert_key(key)
        key.to_s
      end
    end
  end
end

Version data entries

141 entries across 128 versions & 18 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/faraday-1.2.0/lib/faraday/utils/params_hash.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
faraday-1.4.2 lib/faraday/utils/params_hash.rb
cocRb-0.1.0 .bundle/ruby/3.0.0/gems/faraday-1.4.1/lib/faraday/utils/params_hash.rb
faraday-1.4.1 lib/faraday/utils/params_hash.rb
faraday-1.4.0 lib/faraday/utils/params_hash.rb
faraday-1.3.1 lib/faraday/utils/params_hash.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/faraday-1.2.0/lib/faraday/utils/params_hash.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/faraday-1.3.0/lib/faraday/utils/params_hash.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/faraday-1.3.0/lib/faraday/utils/params_hash.rb
faraday-1.3.0 lib/faraday/utils/params_hash.rb
faraday-1.2.0 lib/faraday/utils/params_hash.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/utils/params_hash.rb
faraday-1.1.0 lib/faraday/utils/params_hash.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/lib/faraday/utils/params_hash.rb