Class: Mrkt::Faraday::ParamsEncoder

Inherits:
Object
  • Object
show all
Defined in:
lib/mrkt/faraday/params_encoder.rb

Class Method Summary collapse

Class Method Details

.decode(string) ⇒ Object


10
11
12
# File 'lib/mrkt/faraday/params_encoder.rb', line 10

def decode(string)
  ::Faraday::NestedParamsEncoder.decode(string)
end

.encode(hash) ⇒ Object


5
6
7
8
# File 'lib/mrkt/faraday/params_encoder.rb', line 5

def encode(hash)
  new_hash = hash.transform_values { |v| encode_value(v) }
  ::Faraday::NestedParamsEncoder.encode(new_hash)
end

.encode_value(value) ⇒ Object


14
15
16
# File 'lib/mrkt/faraday/params_encoder.rb', line 14

def encode_value(value)
  value.respond_to?(:join) ? value.join(',') : value
end