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}Z\Z/m
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.
9 10 11 12 |
# File 'lib/faraday_middleware/response/parse_dates.rb', line 9 def initialize(app, = {}) @regexp = [:match] || ISO_DATE_FORMAT super(app) end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 |
# File 'lib/faraday_middleware/response/parse_dates.rb', line 14 def call(env) response = @app.call(env) parse_dates! response.env[:body] response end |