Sha256: dd1233ccf4c06e2b38e6f5fe7cfc1baef8a38607b233390a87380da1ff1bc032

Contents?: true

Size: 666 Bytes

Versions: 8

Compression:

Stored size: 666 Bytes

Contents

module Faraday
  class Response::ActiveSupportJson < Response::Middleware
    begin
      if !defined?(ActiveSupport::JSON)
        require 'active_support'
        ActiveSupport::JSON
      end

      def self.register_on_complete(env)
        env[:response].on_complete do |finished_env|
          finished_env[:body] = parse(finished_env[:body])

        end
      end
    rescue LoadError, NameError => e
      self.load_error = e
    end

    def initialize(app)
      super
      @parser = nil
    end

    def self.parse(body)
      ActiveSupport::JSON.decode(body)
    rescue Object => err
      raise Faraday::Error::ParsingError.new(err)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
faraday-0.5.6 lib/faraday/response/active_support_json.rb
faraday-0.5.6.pre lib/faraday/response/active_support_json.rb
faraday-0.5.5 lib/faraday/response/active_support_json.rb
faraday-0.5.4 lib/faraday/response/active_support_json.rb
faraday-0.5.3 lib/faraday/response/active_support_json.rb
faraday-0.5.2 lib/faraday/response/active_support_json.rb
faraday-0.5.1 lib/faraday/response/active_support_json.rb
faraday-0.5.0 lib/faraday/response/active_support_json.rb