Sha256: eff06f3e0523a328df3ad5cd19005931002737fdeb3ff52f4fcc3c774e00aeaf

Contents?: true

Size: 421 Bytes

Versions: 8

Compression:

Stored size: 421 Bytes

Contents

require 'faraday'
require 'multi_json'

module Flattr
  module Response
    class ParseJson < Faraday::Response::Middleware

      def parse(body)
        case body
        when ''
          nil
        when 'true'
          true
        when 'false'
          false
        else
          begin
            ::MultiJson.decode(body)
          rescue
            nil
          end
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
flattr-0.3.7 lib/flattr/response/parse_json.rb
flattr-0.3.6 lib/flattr/response/parse_json.rb
flattr-0.3.5 lib/flattr/response/parse_json.rb
flattr-0.3.4 lib/flattr/response/parse_json.rb
flattr-0.3.3 lib/flattr/response/parse_json.rb
flattr-0.3.2 lib/flattr/response/parse_json.rb
flattr-0.3.1 lib/flattr/response/parse_json.rb
flattr-0.3.0 lib/flattr/response/parse_json.rb