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



108
109
110
# File 'lib/faraday/utils.rb', line 108

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

#[]=(key, value) ⇒ Object



112
113
114
# File 'lib/faraday/utils.rb', line 112

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

#delete(key) ⇒ Object



116
117
118
# File 'lib/faraday/utils.rb', line 116

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

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



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

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

#merge(params) ⇒ Object



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

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

#merge_query(query, encoder = nil) ⇒ Object



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

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

#replace(other) ⇒ Object



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

def replace(other)
  clear
  update(other)
end

#to_query(encoder = nil) ⇒ Object



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

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

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



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

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