Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup

  • Loading branch information...
commit 002ff62dcc764437f776032043a39ae649313b5c 1 parent 77e5a92
Erik Michaels-Ober sferik authored
Showing with 21 additions and 11 deletions.
  1. +21 −11 lib/faraday/parse.rb
32 lib/faraday/parse.rb
View
@@ -12,18 +12,9 @@ def self.register_on_complete(env)
response[:body] = begin
case response[:response_headers]['content-type']
when /application\/json/
- case response[:body]
- when ''
- nil
- when 'true'
- true
- when 'false'
- false
- else
- ::MultiJson.decode(response[:body])
- end
+ parse_json(response[:body])
when /application\/xml/
- ::MultiXml.parse(response[:body])
+ parse_xml(response[:body])
else
''
end
@@ -35,5 +26,24 @@ def initialize(app)
super
@parser = nil
end
+
+ private
+
+ def parse_json(response_body)
+ case response_body
+ when ''
+ nil
+ when 'true'
+ true
+ when 'false'
+ false
+ else
+ ::MultiJson.decode(response[:body])
+ end
+ end
+
+ def parse_xml
+ ::MultiXml.parse(response_body)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.