Exception: HatiJsonapiError::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- HatiJsonapiError::BaseError
- Defined in:
- lib/hati_jsonapi_error/api_error/base_error.rb
Overview
This is the base error class for all errors in the HatiJsonapiError gem.
Constant Summary collapse
- STR =
''- OBJ =
{}.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#detail ⇒ Object
Returns the value of attribute detail.
-
#id ⇒ Object
Returns the value of attribute id.
-
#links ⇒ Object
Returns the value of attribute links.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#source ⇒ Object
Returns the value of attribute source.
-
#status ⇒ Object
Returns the value of attribute status.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(**attrs) ⇒ BaseError
constructor
A new instance of BaseError.
- #serializable_hash ⇒ Object
-
#to_h ⇒ Object
NOTE: used in lib/hati_jsonapi_error/payload_adapter.rb.
- #to_json(*_args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(**attrs) ⇒ BaseError
Returns a new instance of BaseError.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 11 def initialize(**attrs) @id = attrs[:id] || STR @code = attrs[:code] || STR @title = attrs[:title] || STR @detail = attrs[:detail] || STR @status = attrs[:status] || STR @links = build_links(attrs[:links]) @source = build_source(attrs[:source]) = attrs[:meta] || OBJ super() end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def code @code end |
#detail ⇒ Object
Returns the value of attribute detail.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def detail @detail end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def id @id end |
#links ⇒ Object
Returns the value of attribute links.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def links @links end |
#meta ⇒ Object
Returns the value of attribute meta.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def end |
#source ⇒ Object
Returns the value of attribute source.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def source @source end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def status @status end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 9 def title @title end |
Instance Method Details
#serializable_hash ⇒ Object
43 44 45 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 43 def serializable_hash to_h end |
#to_h ⇒ Object
NOTE: used in lib/hati_jsonapi_error/payload_adapter.rb
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 26 def to_h { id: id, links: links.to_h, status: status, code: code, title: title, detail: detail, source: source.to_h, meta: } end |
#to_json(*_args) ⇒ Object
47 48 49 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 47 def to_json(*_args) serializable_hash.to_json end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/hati_jsonapi_error/api_error/base_error.rb', line 39 def to_s to_h.to_s end |