Class: Response::StockTwitsErrors
- Inherits:
-
Middleware
- Object
- Middleware
- Response::StockTwitsErrors
- Defined in:
- lib/stocktwits/errors.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ StockTwitsErrors
constructor
A new instance of StockTwitsErrors.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app) ⇒ StockTwitsErrors
Returns a new instance of StockTwitsErrors.
6 7 8 |
# File 'lib/stocktwits/errors.rb', line 6 def initialize(app) super app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/stocktwits/errors.rb', line 10 def call(env) # Handle request # Always call super last super end |
#on_complete(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/stocktwits/errors.rb', line 17 def on_complete(env) # Handle response body = JSON.parse(env[:body]) status = body["response"]["status"] case status when 200 env[:body] else env[:body] = body["errors"][0] end end |