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



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

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

#[]=(key, value) ⇒ Object



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

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

#delete(key) ⇒ Object



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

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

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

Returns:

  • (Boolean)


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

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

#merge(params) ⇒ Object



156
157
158
# File 'lib/faraday/utils.rb', line 156

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

#merge_query(query, encoder = nil) ⇒ Object



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

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

#replace(other) ⇒ Object



160
161
162
163
# File 'lib/faraday/utils.rb', line 160

def replace(other)
  clear
  update(other)
end

#to_query(encoder = nil) ⇒ Object



172
173
174
# File 'lib/faraday/utils.rb', line 172

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

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



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

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