Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 21, 2010
1 parent 77e5a92 commit 002ff62
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/faraday/parse.rb
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 002ff62

Please sign in to comment.