Sha256: 00667e1e321496fff26029033474bb0dc3aa03ec8c6d2befadac2ccefd1dc1bb

Contents?: true

Size: 759 Bytes

Versions: 3

Compression:

Stored size: 759 Bytes

Contents

module Her
  module Model
    # remove deprecated data method since cassinatra returns data: []
    module DeprecatedMethods
      remove_method :data
      remove_method :data=
    end
  end
  module Middleware
    class ParseJSON < Faraday::Response::Middleware
      # @private
      def parse_json(body = nil)
        body ||= '{}'
        message = "Response from the API must behave like a Hash or an Array (last JSON response was #{body.inspect})"

        json = begin
          Yajl.load(body, :symbolize_keys => true)
        rescue MultiJson::LoadError
          raise Her::Errors::ParseError, message
        end

        raise Her::Errors::ParseError, message unless json.is_a?(Hash) or json.is_a?(Array)

        json
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
quandl_cassinatra-0.0.5 lib/quandl/her/patch.rb
quandl_client-0.0.11 lib/quandl/her/patch.rb
quandl_cassinatra-0.0.4 lib/quandl/her/patch.rb