Class: Twitter::Response::ParseJson
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Twitter::Response::ParseJson
- Defined in:
- lib/twitter/response/parse_json.rb
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
21 22 23 24 25 |
# File 'lib/twitter/response/parse_json.rb', line 21 def on_complete(env) if respond_to? :parse env[:body] = parse(env[:body]) unless env[:request][:raw] or [204,304].index env[:status] end end |
#parse(body) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/twitter/response/parse_json.rb', line 8 def parse(body) case body when '' nil when 'true' true when 'false' false else ::MultiJson.decode(body) end end |