Class: Faraday::Utils::ParamsHash

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

Overview

A hash with stringified keys.

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



7
8
9
# File 'lib/faraday/utils/params_hash.rb', line 7

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

#[]=(key, value) ⇒ Object



11
12
13
# File 'lib/faraday/utils/params_hash.rb', line 11

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

#delete(key) ⇒ Object



15
16
17
# File 'lib/faraday/utils/params_hash.rb', line 15

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

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/faraday/utils/params_hash.rb', line 19

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

#merge(params) ⇒ Object



35
36
37
# File 'lib/faraday/utils/params_hash.rb', line 35

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

#merge_query(query, encoder = nil) ⇒ Object



44
45
46
47
48
# File 'lib/faraday/utils/params_hash.rb', line 44

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

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

#replace(other) ⇒ Object



39
40
41
42
# File 'lib/faraday/utils/params_hash.rb', line 39

def replace(other)
  clear
  update(other)
end

#to_query(encoder = nil) ⇒ Object



50
51
52
# File 'lib/faraday/utils/params_hash.rb', line 50

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

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



27
28
29
30
31
32
# File 'lib/faraday/utils/params_hash.rb', line 27

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