Class: JsonApiClient::ErrorCollector::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api_client/error_collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Error

Returns a new instance of Error.



6
7
8
# File 'lib/json_api_client/error_collector.rb', line 6

def initialize(attrs = {})
  @attrs = (attrs || {}).with_indifferent_access
end

Instance Method Details

#aboutObject



14
15
16
17
# File 'lib/json_api_client/error_collector.rb', line 14

def about
  res = attrs.fetch(:links, {})
  res ? res[:about] : {}
end

#codeObject



23
24
25
# File 'lib/json_api_client/error_collector.rb', line 23

def code
  attrs[:code]
end

#detailObject



31
32
33
# File 'lib/json_api_client/error_collector.rb', line 31

def detail
  attrs[:detail]
end

#idObject



10
11
12
# File 'lib/json_api_client/error_collector.rb', line 10

def id
  attrs[:id]
end

#metaObject



56
57
58
# File 'lib/json_api_client/error_collector.rb', line 56

def meta
  MetaData.new(attrs.fetch(:meta, {}))
end

#sourceObject



51
52
53
54
# File 'lib/json_api_client/error_collector.rb', line 51

def source
  res = attrs.fetch(:source, {})
  res ? res : {}
end

#source_parameterObject



35
36
37
38
39
40
41
# File 'lib/json_api_client/error_collector.rb', line 35

def source_parameter
  source.fetch(:parameter) do
    source[:pointer] ?
      source[:pointer].split("/").last :
      nil
  end
end

#source_pointerObject



43
44
45
46
47
48
49
# File 'lib/json_api_client/error_collector.rb', line 43

def source_pointer
  source.fetch(:pointer) do
    source[:parameter] ?
      "/data/attributes/#{source[:parameter]}" :
      nil
  end
end

#statusObject



19
20
21
# File 'lib/json_api_client/error_collector.rb', line 19

def status
  attrs[:status]
end

#titleObject



27
28
29
# File 'lib/json_api_client/error_collector.rb', line 27

def title
  attrs[:title]
end