Class: Faraday::Response::ArrForce
- Inherits:
-
Response::Middleware
- Object
- Response::Middleware
- Faraday::Response::ArrForce
- Defined in:
- lib/faraday/response/arr_force.rb
Instance Method Summary collapse
-
#initialize(env = nil, *args) ⇒ ArrForce
constructor
A new instance of ArrForce.
- #parse(body) ⇒ Object
Constructor Details
#initialize(env = nil, *args) ⇒ ArrForce
Returns a new instance of ArrForce.
19 20 21 22 |
# File 'lib/faraday/response/arr_force.rb', line 19 def initialize(env = nil, *args) @to_array = [args.shift].flatten.map { |k| k.to_s } super(env) end |
Instance Method Details
#parse(body) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/faraday/response/arr_force.rb', line 6 def parse(body) return body unless @to_array.any? case body when Hash normalize(body) when Array body.map { |item| item.is_a?(Hash) ? normalize(item) : item } else body end end |