class Served::Serializers::JsonApi::Errors
Wraps all error objects
Attributes
errors[R]
Public Class Methods
new(response)
click to toggle source
# File lib/served/serializers/json_api/errors.rb, line 11 def initialize(response) errors_hash = JSON.parse(response.body) @errors = errors_hash['errors'].map { |error| Error.new(error) } rescue JSON::ParserError @errors = [Error.new(status: response.code, title: 'Parsing Error', detail: 'Service responded with an unparsable body')] end
Public Instance Methods
each(&block)
click to toggle source
# File lib/served/serializers/json_api/errors.rb, line 19 def each(&block) errors.each(&block) end