Sha256: 60e9fba984ff4e3d639047fd036a00a671594733648b8ff2284d3306ba4c9dec
Contents?: true
Size: 600 Bytes
Versions: 1
Compression:
Stored size: 600 Bytes
Contents
module Restorm module Middleware class ParseJSON < Faraday::Middleware # @private def parse_json(body = nil) body = '{}' if body.blank? message = "Response from the API must behave like a Hash or an Array (last JSON response was #{body.inspect})" json = begin MultiJson.load(body, :symbolize_keys => true) rescue MultiJson::LoadError raise Restorm::Errors::ParseError, message end raise Restorm::Errors::ParseError, message unless json.is_a?(Hash) || json.is_a?(Array) json end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restorm-1.0.0 | lib/restorm/middleware/parse_json.rb |