Class: PuppetRestClient::Response::ParseJSON
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- PuppetRestClient::Response::ParseJSON
- Defined in:
- lib/puppet-rest/response/parse_json.rb
Instance Method Summary collapse
-
#on_complete(env) ⇒ Object
def parse.
- #parse(body) ⇒ Object
Instance Method Details
#on_complete(env) ⇒ Object
def parse
18 19 20 21 22 |
# File 'lib/puppet-rest/response/parse_json.rb', line 18 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
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/puppet-rest/response/parse_json.rb', line 5 def parse(body) case body when '' nil when 'true' true when 'false' false else MultiJson.load(body) end end |