Class: Faraday::Rashify::Middleware
- Inherits:
-
Middleware
- Object
- Middleware
- Faraday::Rashify::Middleware
- Defined in:
- lib/faraday/rashify.rb
Overview
This is a middleware which acts on responses, so it implements ‘on_complete`.
Constant Summary collapse
- CONTENT_TYPE =
'Content-Type'
Instance Method Summary collapse
-
#initialize(app = nil, options = {}) ⇒ Middleware
constructor
Public: Converts parsed response bodies to a Hashie::Mash::Rash if they were of Hash or Array type.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app = nil, options = {}) ⇒ Middleware
Public: Converts parsed response bodies to a Hashie::Mash::Rash if they were of Hash or Array type.
17 18 19 20 21 |
# File 'lib/faraday/rashify.rb', line 17 def initialize(app = nil, = {}) super(app) @options = @content_types = Array([:content_type]) end |
Instance Method Details
#on_complete(env) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/faraday/rashify.rb', line 23 def on_complete(env) # return early if we should not process this request return unless should_process?(env) env[:body] = parse(env[:body]) end |