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


137
138
139
# File 'lib/faraday/utils.rb', line 137

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

#[]=(key, value) ⇒ Object


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

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

#delete(key) ⇒ Object


145
146
147
# File 'lib/faraday/utils.rb', line 145

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

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

Returns:

  • (Boolean)

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

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

#merge(params) ⇒ Object


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

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

#merge_query(query, encoder = nil) ⇒ Object


174
175
176
177
178
179
# File 'lib/faraday/utils.rb', line 174

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

#replace(other) ⇒ Object


169
170
171
172
# File 'lib/faraday/utils.rb', line 169

def replace(other)
  clear
  update(other)
end

#to_query(encoder = nil) ⇒ Object


181
182
183
# File 'lib/faraday/utils.rb', line 181

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

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


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

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