Class: Faraday::Utils::ParamsHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/faraday/utils.rb

Overview

hash with stringified keys

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



120
121
122
# File 'lib/faraday/utils.rb', line 120

def [](key)
  super(convert_key(key))
end

#[]=(key, value) ⇒ Object



124
125
126
# File 'lib/faraday/utils.rb', line 124

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

#delete(key) ⇒ Object



128
129
130
# File 'lib/faraday/utils.rb', line 128

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

#include?(key) ⇒ Boolean Also known as: has_key?, member?, key?

Returns:

  • (Boolean)


132
133
134
# File 'lib/faraday/utils.rb', line 132

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

#merge(params) ⇒ Object



148
149
150
# File 'lib/faraday/utils.rb', line 148

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

#merge_query(query, encoder = nil) ⇒ Object



157
158
159
160
161
162
# File 'lib/faraday/utils.rb', line 157

def merge_query(query, encoder = nil)
  if query && !query.empty?
    update((encoder || Utils.default_params_encoder).decode(query))
  end
  self
end

#replace(other) ⇒ Object



152
153
154
155
# File 'lib/faraday/utils.rb', line 152

def replace(other)
  clear
  update(other)
end

#to_query(encoder = nil) ⇒ Object



164
165
166
# File 'lib/faraday/utils.rb', line 164

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

#update(params) ⇒ Object Also known as: merge!



140
141
142
143
144
145
# File 'lib/faraday/utils.rb', line 140

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