Class: Faraday::Response::FlattenBody
- Inherits:
-
Response::Middleware
- Object
- Response::Middleware
- Faraday::Response::FlattenBody
- Defined in:
- lib/faraday/response/flatten_body.rb
Overview
FlattenBody is a middleware that flattens the response body, and also extends Hashie::Mash instances with a module that allows them to work properly with DelegateClass.
Instance Method Summary collapse
Instance Method Details
#parse(body) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/faraday/response/flatten_body.rb', line 8 def parse(body) return body unless body.respond_to?(:to_a) flattened_response = body.to_a.flatten flattened_response.keep_if { |item| ::Hashie::Mash === item } flattened_response.map do |mash| # extend so that #respond_to? works nicely with DelegateClass mash.extend(LetsFreckle::Extensions::Mash) end end |