Class: JSONAPI::Consumer::ErrorCollector::Error
- Inherits:
-
Object
- Object
- JSONAPI::Consumer::ErrorCollector::Error
- Defined in:
- lib/jsonapi/consumer/error_collector.rb
Instance Method Summary collapse
- #about ⇒ Object
- #code ⇒ Object
- #detail ⇒ Object
- #error_key ⇒ Object
- #error_msg ⇒ Object
- #id ⇒ Object
-
#initialize(attrs = {}) ⇒ Error
constructor
A new instance of Error.
- #meta ⇒ Object
- #source ⇒ Object
- #source_parameter ⇒ Object
- #source_pointer ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Error
Returns a new instance of Error.
6 7 8 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 6 def initialize(attrs = {}) @attrs = (attrs || {}).with_indifferent_access end |
Instance Method Details
#about ⇒ Object
14 15 16 17 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 14 def about res = attrs.fetch(:links, {}) res ? res[:about] : {} end |
#code ⇒ Object
23 24 25 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 23 def code attrs[:code] end |
#detail ⇒ Object
31 32 33 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 31 def detail attrs[:detail] end |
#error_key ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 43 def error_key if source_pointer && source_pointer != "/data" source_pointer.split("/").last else "base" end end |
#error_msg ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 51 def error_msg msg = title || detail || "invalid" if source_parameter "#{source_parameter} #{msg}" else msg end end |
#id ⇒ Object
10 11 12 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 10 def id attrs[:id] end |
#meta ⇒ Object
65 66 67 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 65 def MetaData.new(attrs.fetch(:meta, {})) end |
#source ⇒ Object
60 61 62 63 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 60 def source res = attrs.fetch(:source, {}) res ? res : {} end |
#source_parameter ⇒ Object
35 36 37 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 35 def source_parameter source[:parameter] end |
#source_pointer ⇒ Object
39 40 41 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 39 def source_pointer source[:pointer] end |
#status ⇒ Object
19 20 21 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 19 def status attrs[:status] end |
#title ⇒ Object
27 28 29 |
# File 'lib/jsonapi/consumer/error_collector.rb', line 27 def title attrs[:title] end |