Sha256: 4aa6f38af9521b029a57da4741258f585b3a76334c41420a58b6f7335de2b4fb

Contents?: true

Size: 501 Bytes

Versions: 3

Compression:

Stored size: 501 Bytes

Contents

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

      def parse(body)
        case body
        when ''
          nil
        when 'true'
          true
        when 'false'
          false
        else
          MultiJson.load(body, :symbolize_keys => true)
        end
      end

      def on_complete(env)
        if respond_to?(:parse)
          env[:body] = parse(env[:body]) unless [204, 304].include?(env[:status])
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vulndbhq-0.1.1 lib/vulndbhq/response/parse_json.rb
vulndbhq-0.1.0 lib/vulndbhq/response/parse_json.rb
vulndbhq-0.0.1.beta lib/vulndbhq/response/parse_json.rb