json_api_client 1.22.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +20 -20
- data/README.md +723 -705
- data/Rakefile +32 -32
- data/lib/json_api_client/associations/base_association.rb +33 -33
- data/lib/json_api_client/associations/belongs_to.rb +31 -31
- data/lib/json_api_client/associations/has_many.rb +7 -7
- data/lib/json_api_client/associations/has_one.rb +16 -16
- data/lib/json_api_client/associations.rb +7 -7
- data/lib/json_api_client/connection.rb +41 -41
- data/lib/json_api_client/error_collector.rb +91 -91
- data/lib/json_api_client/errors.rb +125 -125
- data/lib/json_api_client/formatter.rb +145 -145
- data/lib/json_api_client/helpers/associatable.rb +88 -88
- data/lib/json_api_client/helpers/callbacks.rb +27 -27
- data/lib/json_api_client/helpers/dirty.rb +75 -75
- data/lib/json_api_client/helpers/dynamic_attributes.rb +78 -78
- data/lib/json_api_client/helpers/uri.rb +9 -9
- data/lib/json_api_client/helpers.rb +9 -9
- data/lib/json_api_client/implementation.rb +11 -11
- data/lib/json_api_client/included_data.rb +58 -58
- data/lib/json_api_client/linking/links.rb +21 -21
- data/lib/json_api_client/linking/top_level_links.rb +39 -39
- data/lib/json_api_client/linking.rb +5 -5
- data/lib/json_api_client/meta_data.rb +19 -19
- data/lib/json_api_client/middleware/json_request.rb +26 -26
- data/lib/json_api_client/middleware/status.rb +67 -67
- data/lib/json_api_client/middleware.rb +6 -7
- data/lib/json_api_client/paginating/nested_param_paginator.rb +140 -140
- data/lib/json_api_client/paginating/paginator.rb +89 -89
- data/lib/json_api_client/paginating.rb +6 -6
- data/lib/json_api_client/parsers/parser.rb +102 -102
- data/lib/json_api_client/parsers.rb +4 -4
- data/lib/json_api_client/query/builder.rb +239 -239
- data/lib/json_api_client/query/requestor.rb +73 -73
- data/lib/json_api_client/query.rb +5 -5
- data/lib/json_api_client/relationships/relations.rb +55 -55
- data/lib/json_api_client/relationships/top_level_relations.rb +30 -30
- data/lib/json_api_client/relationships.rb +5 -5
- data/lib/json_api_client/request_params.rb +57 -57
- data/lib/json_api_client/resource.rb +671 -658
- data/lib/json_api_client/result_set.rb +25 -25
- data/lib/json_api_client/schema.rb +154 -154
- data/lib/json_api_client/utils.rb +53 -53
- data/lib/json_api_client/version.rb +3 -3
- data/lib/json_api_client.rb +30 -30
- metadata +74 -36
- data/lib/json_api_client/middleware/parse_json.rb +0 -31
data/Rakefile
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'bundler/setup'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
require 'rdoc/task'
|
|
8
|
-
|
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
-
rdoc.title = 'JsonApiClient'
|
|
12
|
-
rdoc.options << '--line-numbers'
|
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Bundler::GemHelper.install_tasks
|
|
21
|
-
|
|
22
|
-
require 'rake/testtask'
|
|
23
|
-
|
|
24
|
-
Rake::TestTask.new(:test) do |t|
|
|
25
|
-
t.libs << 'lib'
|
|
26
|
-
t.libs << 'test'
|
|
27
|
-
t.pattern = 'test/**/*_test.rb'
|
|
28
|
-
t.verbose = false
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
task default: :test
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'JsonApiClient'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Bundler::GemHelper.install_tasks
|
|
21
|
+
|
|
22
|
+
require 'rake/testtask'
|
|
23
|
+
|
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
|
25
|
+
t.libs << 'lib'
|
|
26
|
+
t.libs << 'test'
|
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
|
28
|
+
t.verbose = false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
task default: :test
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
module Associations
|
|
3
|
-
class BaseAssociation
|
|
4
|
-
attr_reader :attr_name, :klass, :options
|
|
5
|
-
def initialize(attr_name, klass, options = {})
|
|
6
|
-
@attr_name = attr_name
|
|
7
|
-
@klass = klass
|
|
8
|
-
@options = options
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def association_class
|
|
12
|
-
@association_class ||= Utils.compute_type(klass, options.fetch(:class_name) do
|
|
13
|
-
attr_name.to_s.classify
|
|
14
|
-
end)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def data(url)
|
|
18
|
-
from_result_set(association_class.requestor.linked(url))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def from_result_set(result_set)
|
|
22
|
-
result_set.to_a
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def load_records(data)
|
|
26
|
-
data.map do |d|
|
|
27
|
-
record_class = Utils.compute_type(klass, klass.key_formatter.unformat(d["type"]).classify)
|
|
28
|
-
record_class.load id: d["id"]
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
module Associations
|
|
3
|
+
class BaseAssociation
|
|
4
|
+
attr_reader :attr_name, :klass, :options
|
|
5
|
+
def initialize(attr_name, klass, options = {})
|
|
6
|
+
@attr_name = attr_name
|
|
7
|
+
@klass = klass
|
|
8
|
+
@options = options
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def association_class
|
|
12
|
+
@association_class ||= Utils.compute_type(klass, options.fetch(:class_name) do
|
|
13
|
+
attr_name.to_s.classify
|
|
14
|
+
end)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def data(url)
|
|
18
|
+
from_result_set(association_class.requestor.linked(url))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def from_result_set(result_set)
|
|
22
|
+
result_set.to_a
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def load_records(data)
|
|
26
|
+
data.map do |d|
|
|
27
|
+
record_class = Utils.compute_type(klass, klass.key_formatter.unformat(d["type"]).classify)
|
|
28
|
+
record_class.load id: d["id"]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
module Associations
|
|
3
|
-
module BelongsTo
|
|
4
|
-
class Association < BaseAssociation
|
|
5
|
-
include Helpers::URI
|
|
6
|
-
|
|
7
|
-
attr_reader :param
|
|
8
|
-
|
|
9
|
-
def initialize(attr_name, klass, options = {})
|
|
10
|
-
super
|
|
11
|
-
@param = options.fetch(:param, :"#{attr_name}_id").to_sym
|
|
12
|
-
@shallow_path = options.fetch(:shallow_path, false)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def shallow_path?
|
|
16
|
-
@shallow_path
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def to_prefix_path(formatter)
|
|
20
|
-
"#{formatter.format(attr_name.to_s.pluralize)}/%{#{param}}"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def set_prefix_path(attrs, formatter)
|
|
24
|
-
return if shallow_path? && !attrs[param]
|
|
25
|
-
attrs[param] = encode_part(attrs[param]) if attrs.key?(param)
|
|
26
|
-
to_prefix_path(formatter) % attrs
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
module Associations
|
|
3
|
+
module BelongsTo
|
|
4
|
+
class Association < BaseAssociation
|
|
5
|
+
include Helpers::URI
|
|
6
|
+
|
|
7
|
+
attr_reader :param
|
|
8
|
+
|
|
9
|
+
def initialize(attr_name, klass, options = {})
|
|
10
|
+
super
|
|
11
|
+
@param = options.fetch(:param, :"#{attr_name}_id").to_sym
|
|
12
|
+
@shallow_path = options.fetch(:shallow_path, false)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def shallow_path?
|
|
16
|
+
@shallow_path
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_prefix_path(formatter)
|
|
20
|
+
"#{formatter.format(attr_name.to_s.pluralize)}/%{#{param}}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def set_prefix_path(attrs, formatter)
|
|
24
|
+
return if shallow_path? && !attrs[param]
|
|
25
|
+
attrs[param] = encode_part(attrs[param]) if attrs.key?(param)
|
|
26
|
+
to_prefix_path(formatter) % attrs
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
module Associations
|
|
3
|
-
module HasMany
|
|
4
|
-
class Association < BaseAssociation
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
module Associations
|
|
3
|
+
module HasMany
|
|
4
|
+
class Association < BaseAssociation
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
8
|
end
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
module Associations
|
|
3
|
-
module HasOne
|
|
4
|
-
class Association < BaseAssociation
|
|
5
|
-
def from_result_set(result_set)
|
|
6
|
-
result_set.first
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def load_records(data)
|
|
10
|
-
record_class = Utils.compute_type(klass, klass.key_formatter.unformat(data["type"]).classify)
|
|
11
|
-
record_class.load id: data["id"]
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
module Associations
|
|
3
|
+
module HasOne
|
|
4
|
+
class Association < BaseAssociation
|
|
5
|
+
def from_result_set(result_set)
|
|
6
|
+
result_set.first
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def load_records(data)
|
|
10
|
+
record_class = Utils.compute_type(klass, klass.key_formatter.unformat(data["type"]).classify)
|
|
11
|
+
record_class.load id: data["id"]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
module Associations
|
|
3
|
-
autoload :BaseAssociation, 'json_api_client/associations/base_association'
|
|
4
|
-
autoload :BelongsTo, 'json_api_client/associations/belongs_to'
|
|
5
|
-
autoload :HasMany, 'json_api_client/associations/has_many'
|
|
6
|
-
autoload :HasOne, 'json_api_client/associations/has_one'
|
|
7
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
module Associations
|
|
3
|
+
autoload :BaseAssociation, 'json_api_client/associations/base_association'
|
|
4
|
+
autoload :BelongsTo, 'json_api_client/associations/belongs_to'
|
|
5
|
+
autoload :HasMany, 'json_api_client/associations/has_many'
|
|
6
|
+
autoload :HasOne, 'json_api_client/associations/has_one'
|
|
7
|
+
end
|
|
8
8
|
end
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
class Connection
|
|
3
|
-
|
|
4
|
-
attr_reader :faraday
|
|
5
|
-
|
|
6
|
-
def initialize(options = {})
|
|
7
|
-
site = options.fetch(:site)
|
|
8
|
-
connection_options = options.slice(:proxy, :ssl, :request, :headers, :params)
|
|
9
|
-
adapter_options = Array(options.fetch(:adapter, Faraday.default_adapter))
|
|
10
|
-
status_middleware_options = {}
|
|
11
|
-
status_middleware_options[:custom_handlers] = options[:status_handlers] if options[:status_handlers].present?
|
|
12
|
-
@faraday = Faraday.new(site, connection_options) do |builder|
|
|
13
|
-
builder.request :json
|
|
14
|
-
builder.use Middleware::JsonRequest
|
|
15
|
-
builder.use Middleware::Status, status_middleware_options
|
|
16
|
-
builder.
|
|
17
|
-
builder.use ::
|
|
18
|
-
builder.adapter(*adapter_options)
|
|
19
|
-
end
|
|
20
|
-
yield(self) if block_given?
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# insert middleware before ParseJson - middleware executed in reverse order -
|
|
24
|
-
# inserted middleware will run after json parsed
|
|
25
|
-
def use(middleware, *args, &block)
|
|
26
|
-
return if faraday.builder.locked?
|
|
27
|
-
faraday.builder.insert_before(
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def delete(middleware)
|
|
31
|
-
faraday.builder.delete(middleware)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def run(request_method, path, params: nil, headers: {}, body: nil)
|
|
35
|
-
faraday.run_request(request_method, path, body, headers) do |request|
|
|
36
|
-
request.params.update(params) if params
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
class Connection
|
|
3
|
+
|
|
4
|
+
attr_reader :faraday
|
|
5
|
+
|
|
6
|
+
def initialize(options = {})
|
|
7
|
+
site = options.fetch(:site)
|
|
8
|
+
connection_options = options.slice(:proxy, :ssl, :request, :headers, :params)
|
|
9
|
+
adapter_options = Array(options.fetch(:adapter, Faraday.default_adapter))
|
|
10
|
+
status_middleware_options = {}
|
|
11
|
+
status_middleware_options[:custom_handlers] = options[:status_handlers] if options[:status_handlers].present?
|
|
12
|
+
@faraday = Faraday.new(site, connection_options) do |builder|
|
|
13
|
+
builder.request :json
|
|
14
|
+
builder.use Middleware::JsonRequest
|
|
15
|
+
builder.use Middleware::Status, status_middleware_options
|
|
16
|
+
builder.response :json
|
|
17
|
+
builder.use ::Faraday::Gzip::Middleware
|
|
18
|
+
builder.adapter(*adapter_options)
|
|
19
|
+
end
|
|
20
|
+
yield(self) if block_given?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# insert middleware before ParseJson - middleware executed in reverse order -
|
|
24
|
+
# inserted middleware will run after json parsed
|
|
25
|
+
def use(middleware, *args, &block)
|
|
26
|
+
return if faraday.builder.locked?
|
|
27
|
+
faraday.builder.insert_before(::Faraday::Response::Json, middleware, *args, &block)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def delete(middleware)
|
|
31
|
+
faraday.builder.delete(middleware)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def run(request_method, path, params: nil, headers: {}, body: nil)
|
|
35
|
+
faraday.run_request(request_method, path, body, headers) do |request|
|
|
36
|
+
request.params.update(params) if params
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
module JsonApiClient
|
|
2
|
-
class ErrorCollector < Array
|
|
3
|
-
class Error
|
|
4
|
-
delegate :[], to: :attrs
|
|
5
|
-
|
|
6
|
-
def initialize(attrs = {})
|
|
7
|
-
@attrs = (attrs || {}).with_indifferent_access
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def id
|
|
11
|
-
attrs[:id]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def about
|
|
15
|
-
res = attrs.fetch(:links, {})
|
|
16
|
-
res ? res[:about] : {}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def status
|
|
20
|
-
attrs[:status]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def code
|
|
24
|
-
attrs[:code]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def title
|
|
28
|
-
attrs[:title]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def detail
|
|
32
|
-
attrs[:detail]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def source_parameter
|
|
36
|
-
source[:parameter]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def source_pointer
|
|
40
|
-
source[:pointer]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def error_key
|
|
44
|
-
if source_pointer && source_pointer != "/data"
|
|
45
|
-
source_pointer.split("/").last
|
|
46
|
-
else
|
|
47
|
-
"base"
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def error_msg
|
|
52
|
-
msg = title || detail || "invalid"
|
|
53
|
-
if source_parameter
|
|
54
|
-
"#{source_parameter} #{msg}"
|
|
55
|
-
else
|
|
56
|
-
msg
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def source
|
|
61
|
-
res = attrs.fetch(:source, {})
|
|
62
|
-
res ? res : {}
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def meta
|
|
66
|
-
MetaData.new(attrs.fetch(:meta, {}))
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
protected
|
|
70
|
-
|
|
71
|
-
attr_reader :attrs
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def initialize(error_data)
|
|
75
|
-
super(error_data.map do |data|
|
|
76
|
-
Error.new(data)
|
|
77
|
-
end)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def full_messages
|
|
81
|
-
map(&:title)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def [](source)
|
|
85
|
-
map do |error|
|
|
86
|
-
error.error_key == source
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
end
|
|
1
|
+
module JsonApiClient
|
|
2
|
+
class ErrorCollector < Array
|
|
3
|
+
class Error
|
|
4
|
+
delegate :[], to: :attrs
|
|
5
|
+
|
|
6
|
+
def initialize(attrs = {})
|
|
7
|
+
@attrs = (attrs || {}).with_indifferent_access
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def id
|
|
11
|
+
attrs[:id]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def about
|
|
15
|
+
res = attrs.fetch(:links, {})
|
|
16
|
+
res ? res[:about] : {}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def status
|
|
20
|
+
attrs[:status]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def code
|
|
24
|
+
attrs[:code]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def title
|
|
28
|
+
attrs[:title]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def detail
|
|
32
|
+
attrs[:detail]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def source_parameter
|
|
36
|
+
source[:parameter]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def source_pointer
|
|
40
|
+
source[:pointer]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def error_key
|
|
44
|
+
if source_pointer && source_pointer != "/data"
|
|
45
|
+
source_pointer.split("/").last
|
|
46
|
+
else
|
|
47
|
+
"base"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def error_msg
|
|
52
|
+
msg = title || detail || "invalid"
|
|
53
|
+
if source_parameter
|
|
54
|
+
"#{source_parameter} #{msg}"
|
|
55
|
+
else
|
|
56
|
+
msg
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def source
|
|
61
|
+
res = attrs.fetch(:source, {})
|
|
62
|
+
res ? res : {}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def meta
|
|
66
|
+
MetaData.new(attrs.fetch(:meta, {}))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
protected
|
|
70
|
+
|
|
71
|
+
attr_reader :attrs
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def initialize(error_data)
|
|
75
|
+
super(error_data.map do |data|
|
|
76
|
+
Error.new(data)
|
|
77
|
+
end)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def full_messages
|
|
81
|
+
map(&:title)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def [](source)
|
|
85
|
+
map do |error|
|
|
86
|
+
error.error_key == source
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
end
|