class JSONAPI::Serializable::Error

Attributes

code_block[RW]
code_val[RW]
detail_block[RW]
detail_val[RW]
id_block[RW]
id_val[RW]
meta_block[RW]
meta_val[RW]
source_block[RW]
status_block[RW]
status_val[RW]
title_block[RW]
title_val[RW]

Public Class Methods

inherited(klass) click to toggle source
Calls superclass method
# File lib/jsonapi/serializable/error.rb, line 40
def self.inherited(klass)
  super
  klass.link_blocks = link_blocks.dup
end
new(exposures = {}) click to toggle source
# File lib/jsonapi/serializable/error.rb, line 45
def initialize(exposures = {})
  @_exposures = exposures
  exposures.each { |k, v| instance_variable_set("@#{k}", v) }
end

Public Instance Methods

as_jsonapi() click to toggle source
# File lib/jsonapi/serializable/error.rb, line 50
def as_jsonapi
  hash = links.any? ? { links: links } : {}
  [:id, :status, :code, :title, :detail, :meta, :source]
    .each_with_object(hash) do |key, h|
    value = send(key)
    h[key] = value unless value.nil?
  end
end

Private Instance Methods

source() click to toggle source
# File lib/jsonapi/serializable/error.rb, line 67
def source
  return @_source if @_source
  return if self.class.source_block.nil?
  @_source = ErrorSource.as_jsonapi(@_exposures,
                                    &self.class.source_block)
end