Sha256: 5d28e7afa4f395dd9c86df22f6c13b556d1c702c5c62fc6beef118f4a62690b5

Contents?: true

Size: 419 Bytes

Versions: 1

Compression:

Stored size: 419 Bytes

Contents

require 'faraday'

module Smartdc
  module Response
    class ParseJson < Faraday::Response::Middleware
      dependency do
        require 'multi_json'
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartdc-0.4.0 lib/smartdc/response/parse_json.rb