Exception: Served::Serializers::JsonApi::Error
- Inherits:
-
Error
- Object
- StandardError
- Resource::Base::ServiceError
- Error
- Served::Serializers::JsonApi::Error
- Defined in:
- lib/served/serializers/json_api/error.rb
Overview
Error object
Instance Method Summary collapse
- #code ⇒ Object
- #detail ⇒ Object
- #id ⇒ Object
-
#initialize(attrs = {}) ⇒ Error
constructor
A new instance of Error.
- #source ⇒ Object
- #source_parameter ⇒ Object
- #source_pointer ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Error
Returns a new instance of Error.
11 12 13 |
# File 'lib/served/serializers/json_api/error.rb', line 11 def initialize(attrs = {}) @attrs = (attrs || {}).with_indifferent_access end |
Instance Method Details
#code ⇒ Object
23 24 25 |
# File 'lib/served/serializers/json_api/error.rb', line 23 def code attrs[:code] end |
#detail ⇒ Object
31 32 33 |
# File 'lib/served/serializers/json_api/error.rb', line 31 def detail attrs[:detail] end |
#id ⇒ Object
15 16 17 |
# File 'lib/served/serializers/json_api/error.rb', line 15 def id attrs[:id] end |
#source ⇒ Object
47 48 49 50 |
# File 'lib/served/serializers/json_api/error.rb', line 47 def source res = attrs.fetch(:source, {}) res ? res : {} end |
#source_parameter ⇒ Object
35 36 37 38 39 |
# File 'lib/served/serializers/json_api/error.rb', line 35 def source_parameter source.fetch(:parameter) do source[:pointer] ? source[:pointer].split('/').last : nil end end |
#source_pointer ⇒ Object
41 42 43 44 45 |
# File 'lib/served/serializers/json_api/error.rb', line 41 def source_pointer source.fetch(:pointer) do source[:parameter] ? "/data/attributes/#{source[:parameter]}" : nil end end |
#status ⇒ Object
19 20 21 |
# File 'lib/served/serializers/json_api/error.rb', line 19 def status attrs[:status] end |
#title ⇒ Object
27 28 29 |
# File 'lib/served/serializers/json_api/error.rb', line 27 def title attrs[:title] end |