Class: JSONAPI::Serializable::Error

Inherits:
Object
  • Object
show all
Includes:
ErrorDSL
Defined in:
lib/jsonapi/serializable/error.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ErrorDSL

included

Constructor Details

#initialize(exposures = {}) ⇒ Error

Returns a new instance of Error.


45
46
47
48
# File 'lib/jsonapi/serializable/error.rb', line 45

def initialize(exposures = {})
  @_exposures = exposures
  exposures.each { |k, v| instance_variable_set("@#{k}", v) }
end

Class Attribute Details

.code_blockObject

Returns the value of attribute code_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def code_block
  @code_block
end

.code_valObject

Returns the value of attribute code_val


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def code_val
  @code_val
end

.detail_blockObject

Returns the value of attribute detail_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def detail_block
  @detail_block
end

.detail_valObject

Returns the value of attribute detail_val


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def detail_val
  @detail_val
end

.id_blockObject

Returns the value of attribute id_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def id_block
  @id_block
end

.id_valObject

Returns the value of attribute id_val


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def id_val
  @id_val
end

Returns the value of attribute link_blocks


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def link_blocks
  @link_blocks
end

.meta_blockObject

Returns the value of attribute meta_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def meta_block
  @meta_block
end

.meta_valObject

Returns the value of attribute meta_val


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def meta_val
  @meta_val
end

.source_blockObject

Returns the value of attribute source_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def source_block
  @source_block
end

.status_blockObject

Returns the value of attribute status_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def status_block
  @status_block
end

.status_valObject

Returns the value of attribute status_val


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def status_val
  @status_val
end

.title_blockObject

Returns the value of attribute title_block


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def title_block
  @title_block
end

.title_valObject

Returns the value of attribute title_val


32
33
34
# File 'lib/jsonapi/serializable/error.rb', line 32

def title_val
  @title_val
end

Class Method Details

.inherited(klass) ⇒ Object


40
41
42
43
# File 'lib/jsonapi/serializable/error.rb', line 40

def self.inherited(klass)
  super
  klass.link_blocks = link_blocks.dup
end

Instance Method Details

#as_jsonapiObject


50
51
52
53
54
55
56
57
# 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