Sha256: 5b8ea8b81e97e4a0e0d5bf8e57a1a1293fb85512ab4604ec1cfaccb4e8ba139c

Contents?: true

Size: 531 Bytes

Versions: 5

Compression:

Stored size: 531 Bytes

Contents

require 'multi_json'

module Faraday
  class Response::ParseJson < Response::Middleware
    def self.register_on_complete(env)
      env[:response].on_complete do |response|
        response[:body] = begin
          case response[:body]
          when ""
            nil
          when "true"
            true
          when "false"
            false
          else
            MultiJson.decode(response[:body])
          end
        end
      end
    end

    def initialize(app)
      super
      @parser = nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
faraday_middleware-0.1.4 lib/faraday/parse_json.rb
faraday_middleware-0.1.3 lib/faraday/parse_json.rb
faraday_middleware-0.1.2 lib/faraday/parse_json.rb
faraday_middleware-0.1.1 lib/faraday/parse_json.rb
faraday_middleware-0.1.0 lib/faraday/parse_json.rb