Sha256: a2cfa0c60abd633b0e25c3341cae416a3c32bb1ac048f30eb0693bd3582e993e
Contents?: true
Size: 944 Bytes
Versions: 2
Compression:
Stored size: 944 Bytes
Contents
module JSONAPI # c.f. http://jsonapi.org/format/#error-objects class Error attr_reader :id, :links, :status, :code, :title, :detail, :source, :meta def initialize(error_hash, options = {}) fail InvalidDocument, "the value of 'errors' MUST be an array of error objects" unless error_hash.is_a?(Hash) @hash = error_hash @id = error_hash['id'] if error_hash.key?('id') links_hash = error_hash['links'] || {} @links = Links.new(links_hash, options) @status = error_hash['status'] if error_hash.key?('status') @code = error_hash['code'] if error_hash.key?('code') @title = error_hash['title'] if error_hash.key?('title') @detail = error_hash['detail'] if error_hash.key?('detail') @source = error_hash['source'] if error_hash.key?('source') @meta = error_hash['meta'] if error_hash.key?('meta') end def to_hash @hash end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jsonapi-0.1.1.beta2 | lib/jsonapi/error.rb |
jsonapi-0.1.1.beta1 | lib/jsonapi/error.rb |