Class: FaradayMiddleware::ParseDates
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- FaradayMiddleware::ParseDates
- Defined in:
- lib/faraday_middleware/response/parse_dates.rb
Overview
Parse dates from response body
Constant Summary collapse
- ISO_DATE_FORMAT =
/\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)? (Z|((\+|-)\d{2}:?\d{2}))\Z/xm.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ ParseDates
constructor
A new instance of ParseDates.
Constructor Details
#initialize(app, options = {}) ⇒ ParseDates
Returns a new instance of ParseDates.
12 13 14 15 |
# File 'lib/faraday_middleware/response/parse_dates.rb', line 12 def initialize(app, = {}) @regexp = [:match] || ISO_DATE_FORMAT super(app) end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 |
# File 'lib/faraday_middleware/response/parse_dates.rb', line 17 def call(env) response = @app.call(env) parse_dates! response.env[:body] response end |