Sha256: 14af0bc74a6e3a9643d1c70964ba6328d2139a784b59c151e0b515e3dd316728

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 Bytes

Contents

module Faraday
  class Response::MultiJson < Response::Middleware
    begin
      require 'multi_json'

      def self.register_on_complete(env)
        env[:response].on_complete do |finished_env|
          finished_env[:body] = begin
            case finished_env[:body]
            when ""
              nil
            when "true"
              true
            when "false"
              false
            else
              MultiJson.decode(finished_env[:body])
            end
          end
        end
      end
    rescue LoadError, NameError => e
      self.load_error = e
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faraday_middleware-0.0.4 lib/faraday/multi_json.rb