jat 0.0.3 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jat/attribute.rb +26 -5
- data/lib/jat/config.rb +4 -7
- data/lib/jat/plugins/activerecord/activerecord.rb +23 -0
- data/lib/jat/plugins/base/base_activerecord_preloads/base_activerecord_preloads.rb +38 -0
- data/lib/jat/plugins/{_activerecord_preloads → base/base_activerecord_preloads}/lib/preloader.rb +22 -16
- data/lib/jat/plugins/base/base_lower_camel_case/base_lower_camel_case.rb +36 -0
- data/lib/jat/plugins/{_preloads/_preloads.rb → base/base_preloads/base_preloads.rb} +14 -4
- data/lib/jat/plugins/{_preloads → base/base_preloads}/lib/format_user_preloads.rb +1 -1
- data/lib/jat/plugins/{_preloads → base/base_preloads}/lib/preloads_with_path.rb +1 -1
- data/lib/jat/plugins/cache/cache.rb +14 -6
- data/lib/jat/plugins/json_api/json_api.rb +150 -106
- data/lib/jat/plugins/json_api/lib/fields_param_parser.rb +40 -0
- data/lib/jat/plugins/json_api/lib/include_param_parser.rb +84 -0
- data/lib/jat/plugins/json_api/lib/map.rb +92 -27
- data/lib/jat/plugins/json_api/lib/params/fields/validate.rb +8 -5
- data/lib/jat/plugins/json_api/lib/response.rb +81 -197
- data/lib/jat/plugins/json_api/lib/response_piece.rb +175 -0
- data/lib/jat/plugins/json_api/plugins/json_api_activerecord/json_api_activerecord.rb +23 -0
- data/lib/jat/plugins/json_api/plugins/json_api_lower_camel_case/json_api_lower_camel_case.rb +34 -0
- data/lib/jat/plugins/json_api/plugins/json_api_maps_cache/json_api_maps_cache.rb +58 -0
- data/lib/jat/plugins/json_api/plugins/json_api_preloads/json_api_preloads.rb +38 -0
- data/lib/jat/plugins/{_json_api_activerecord → json_api/plugins/json_api_preloads}/lib/preloads.rb +17 -25
- data/lib/jat/plugins/json_api/plugins/json_api_validate_params/json_api_validate_params.rb +61 -0
- data/lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/params_error.rb +6 -0
- data/lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb +59 -0
- data/lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_include_param.rb +33 -0
- data/lib/jat/plugins/lower_camel_case/lower_camel_case.rb +23 -0
- data/lib/jat/plugins/maps_cache/maps_cache.rb +23 -0
- data/lib/jat/plugins/preloads/preloads.rb +23 -0
- data/lib/jat/plugins/simple_api/lib/fields_param_parser.rb +97 -0
- data/lib/jat/plugins/simple_api/lib/map.rb +80 -10
- data/lib/jat/plugins/simple_api/lib/response.rb +75 -90
- data/lib/jat/plugins/simple_api/lib/response_piece.rb +80 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_activerecord/simple_api_activerecord.rb +23 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_lower_camel_case/simple_api_lower_camel_case.rb +34 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_maps_cache/simple_api_maps_cache.rb +50 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_preloads/lib/preloads.rb +55 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_preloads/simple_api_preloads.rb +38 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_validate_params/lib/fields_error.rb +6 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_validate_params/lib/validate_fields_param.rb +45 -0
- data/lib/jat/plugins/simple_api/plugins/simple_api_validate_params/simple_api_validate_params.rb +49 -0
- data/lib/jat/plugins/simple_api/simple_api.rb +87 -27
- data/lib/jat/plugins/to_str/to_str.rb +15 -5
- data/lib/jat/plugins/types/types.rb +54 -0
- data/lib/jat/plugins/validate_params/validate_params.rb +23 -0
- data/lib/jat/plugins.rb +42 -30
- data/lib/jat.rb +40 -35
- data/test/lib/jat/attribute_test.rb +22 -4
- data/test/lib/jat/plugins/activerecord/activerecord_test.rb +27 -0
- data/test/lib/jat/plugins/base_activerecord_preloads/base_activerecord_preloads_test.rb +59 -0
- data/test/lib/jat/plugins/{_activerecord_preloads → base_activerecord_preloads}/lib/preloader_test.rb +11 -25
- data/test/lib/jat/plugins/base_lower_camel_case/base_lower_camel_case_test.rb +26 -0
- data/test/lib/jat/plugins/{_preloads/_preloads_test.rb → base_preloads/base_preloads_test.rb} +2 -2
- data/test/lib/jat/plugins/{_preloads → base_preloads}/lib/format_user_preloads_test.rb +3 -3
- data/test/lib/jat/plugins/{_preloads → base_preloads}/lib/preloads_with_path_test.rb +2 -2
- data/test/lib/jat/plugins/cache/cache_test.rb +11 -11
- data/test/lib/jat/plugins/json_api/json_api_test.rb +57 -49
- data/test/lib/jat/plugins/json_api/lib/fields_param_parser_test.rb +46 -0
- data/test/lib/jat/plugins/json_api/lib/include_param_parser_test.rb +57 -0
- data/test/lib/jat/plugins/json_api/lib/map_test.rb +171 -92
- data/test/lib/jat/plugins/json_api/lib/response_piece_test.rb +13 -0
- data/test/lib/jat/plugins/json_api/lib/response_test.rb +38 -32
- data/test/lib/jat/plugins/json_api_activerecord/json_api_activerecord_test.rb +24 -0
- data/test/lib/jat/plugins/json_api_lower_camel_case/json_api_lower_camel_case_test.rb +85 -0
- data/test/lib/jat/plugins/json_api_maps_cache/json_api_maps_cache_test.rb +107 -0
- data/test/lib/jat/plugins/json_api_preloads/json_api_preloads_test.rb +51 -0
- data/test/lib/jat/plugins/{_json_api_activerecord → json_api_preloads}/lib/preloads_test.rb +19 -13
- data/test/lib/jat/plugins/json_api_validate_params/json_api_validate_params_test.rb +108 -0
- data/test/lib/jat/plugins/lower_camel_case/lower_camel_case_test.rb +27 -0
- data/test/lib/jat/plugins/maps_cache/maps_cache_test.rb +27 -0
- data/test/lib/jat/plugins/preloads/preloads_test.rb +27 -0
- data/test/lib/jat/plugins/simple_api/lib/fields_param_parser_test.rb +87 -0
- data/test/lib/jat/plugins/simple_api/lib/map_test.rb +118 -33
- data/test/lib/jat/plugins/simple_api/lib/response_piece_test.rb +13 -0
- data/test/lib/jat/plugins/simple_api/lib/response_test.rb +90 -76
- data/test/lib/jat/plugins/simple_api/simple_api_test.rb +118 -25
- data/test/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord_test.rb +24 -0
- data/test/lib/jat/plugins/simple_api_lower_camel_case/simple_api_lower_camel_case_test.rb +54 -0
- data/test/lib/jat/plugins/simple_api_maps_cache/simple_api_maps_cache_test.rb +95 -0
- data/test/lib/jat/plugins/simple_api_preloads/lib/preloads_test.rb +140 -0
- data/test/lib/jat/plugins/simple_api_preloads/simple_api_preloads_test.rb +51 -0
- data/test/lib/jat/plugins/simple_api_validate_params/simple_api_validate_params_test.rb +101 -0
- data/test/lib/jat/plugins/to_str/to_str_test.rb +3 -3
- data/test/lib/jat/plugins/types/types_test.rb +84 -0
- data/test/lib/jat/plugins/validate_params/validate_params_test.rb +27 -0
- data/test/lib/jat/plugins_test.rb +88 -0
- data/test/lib/jat_test.rb +47 -24
- data/test/lib/plugin_test.rb +3 -3
- data/test/test_helper.rb +7 -6
- data/test/test_plugin.rb +9 -12
- metadata +107 -88
- data/CHANGELOG.md +0 -7
- data/README.md +0 -21
- data/jat.gemspec +0 -37
- data/lib/jat/plugins/_activerecord_preloads/_activerecord_preloads.rb +0 -29
- data/lib/jat/plugins/_json_api_activerecord/_json_api_activerecord.rb +0 -22
- data/lib/jat/plugins/camel_lower/camel_lower.rb +0 -18
- data/lib/jat/plugins/json_api/lib/construct_traversal_map.rb +0 -91
- data/lib/jat/plugins/json_api/lib/presenters/document_links_presenter.rb +0 -48
- data/lib/jat/plugins/json_api/lib/presenters/document_meta_presenter.rb +0 -48
- data/lib/jat/plugins/json_api/lib/presenters/jsonapi_presenter.rb +0 -48
- data/lib/jat/plugins/json_api/lib/presenters/links_presenter.rb +0 -48
- data/lib/jat/plugins/json_api/lib/presenters/meta_presenter.rb +0 -48
- data/lib/jat/plugins/json_api/lib/presenters/relationship_links_presenter.rb +0 -53
- data/lib/jat/plugins/json_api/lib/presenters/relationship_meta_presenter.rb +0 -53
- data/lib/jat/plugins/json_api/lib/traversal_map.rb +0 -34
- data/lib/jat/plugins/simple_api/lib/construct_traversal_map.rb +0 -45
- data/lib/jat/plugins/simple_api/lib/params/parse.rb +0 -68
- data/lib/jat/presenter.rb +0 -51
- data/test/lib/jat/plugins/_activerecord_preloads/_activerecord_preloads_test.rb +0 -40
- data/test/lib/jat/plugins/_json_api_activerecord/_json_api_activerecord_test.rb +0 -29
- data/test/lib/jat/plugins/camel_lower/camel_lower_test.rb +0 -78
- data/test/lib/jat/plugins/json_api/lib/construct_traversal_map_test.rb +0 -119
- data/test/lib/jat/plugins/json_api/lib/params/fields/parse_test.rb +0 -24
- data/test/lib/jat/plugins/json_api/lib/params/fields/validate_test.rb +0 -47
- data/test/lib/jat/plugins/json_api/lib/params/fields_test.rb +0 -37
- data/test/lib/jat/plugins/json_api/lib/params/include/parse_test.rb +0 -46
- data/test/lib/jat/plugins/json_api/lib/params/include/validate_test.rb +0 -51
- data/test/lib/jat/plugins/json_api/lib/params/include_test.rb +0 -41
- data/test/lib/jat/plugins/json_api/lib/presenters/document_links_presenter_test.rb +0 -69
- data/test/lib/jat/plugins/json_api/lib/presenters/document_meta_presenter_test.rb +0 -69
- data/test/lib/jat/plugins/json_api/lib/presenters/jsonapi_presenter_test.rb +0 -69
- data/test/lib/jat/plugins/json_api/lib/presenters/links_presenter_test.rb +0 -69
- data/test/lib/jat/plugins/json_api/lib/presenters/meta_presenter_test.rb +0 -69
- data/test/lib/jat/plugins/json_api/lib/presenters/relationship_links_presenter_test.rb +0 -75
- data/test/lib/jat/plugins/json_api/lib/presenters/relationship_meta_presenter_test.rb +0 -75
- data/test/lib/jat/plugins/json_api/lib/traversal_map_test.rb +0 -58
- data/test/lib/jat/plugins/simple_api/lib/construct_traversal_map_test.rb +0 -100
- data/test/lib/jat/plugins/simple_api/lib/params/parse_test.rb +0 -71
- data/test/lib/jat/presenter_test.rb +0 -61
data/test/lib/jat_test.rb
CHANGED
@@ -6,19 +6,36 @@ describe Jat do
|
|
6
6
|
let(:jat_class) { Class.new(Jat) }
|
7
7
|
|
8
8
|
describe ".plugin" do
|
9
|
-
it "
|
10
|
-
plugin =
|
11
|
-
|
9
|
+
it "loads same plugin only once" do
|
10
|
+
plugin = Module.new
|
11
|
+
jat_class.plugin plugin
|
12
|
+
jat_class.plugin plugin
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
assert_equal [plugin], jat_class.config[:plugins]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".plugin_used?" do
|
19
|
+
it "tells if plugin has been already used in current serializer" do
|
20
|
+
assert_equal false, jat_class.plugin_used?(:json_api)
|
21
|
+
jat_class.plugin(:json_api)
|
22
|
+
assert_equal true, jat_class.plugin_used?(:json_api)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "accepts Module" do
|
26
|
+
plugin = Module.new
|
27
|
+
|
28
|
+
assert_equal false, jat_class.plugin_used?(plugin)
|
29
|
+
jat_class.plugin(plugin)
|
30
|
+
assert_equal true, jat_class.plugin_used?(plugin)
|
15
31
|
end
|
16
32
|
end
|
17
33
|
|
18
34
|
describe ".config" do
|
19
|
-
it "returns config object" do
|
35
|
+
it "returns config object with default values" do
|
20
36
|
config = jat_class.config
|
21
37
|
assert_equal jat_class::Config, config.class
|
38
|
+
assert_equal({plugins: []}, config.opts)
|
22
39
|
end
|
23
40
|
end
|
24
41
|
|
@@ -40,11 +57,6 @@ describe Jat do
|
|
40
57
|
assert_equal parent::Attribute, child::Attribute.superclass
|
41
58
|
assert child.attributes[:foo]
|
42
59
|
end
|
43
|
-
|
44
|
-
it "inherits presenter" do
|
45
|
-
child = Class.new(parent)
|
46
|
-
assert_equal parent::Presenter, child::Presenter.superclass
|
47
|
-
end
|
48
60
|
end
|
49
61
|
|
50
62
|
describe ".call" do
|
@@ -54,6 +66,8 @@ describe Jat do
|
|
54
66
|
end
|
55
67
|
|
56
68
|
describe ".to_h" do
|
69
|
+
let(:jat) { jat_class.allocate }
|
70
|
+
|
57
71
|
it "raises error that we should add some response generation plugin" do
|
58
72
|
error = assert_raises(Jat::Error) { jat_class.to_h(nil) }
|
59
73
|
|
@@ -61,13 +75,15 @@ describe Jat do
|
|
61
75
|
assert_equal error_message, error.message
|
62
76
|
end
|
63
77
|
|
64
|
-
it "initializes serializer instance with provided
|
65
|
-
|
78
|
+
it "initializes serializer instance with provided context" do
|
79
|
+
jat.expects(:to_h).with("obj")
|
80
|
+
jat_class.expects(:new).with("context").returns(jat)
|
66
81
|
jat_class.to_h("obj", "context")
|
67
82
|
end
|
68
83
|
|
69
84
|
it "adds empty hash context when context not provided" do
|
70
|
-
|
85
|
+
jat.expects(:to_h).with("obj")
|
86
|
+
jat_class.expects(:new).with({}).returns(jat)
|
71
87
|
jat_class.to_h("obj")
|
72
88
|
end
|
73
89
|
end
|
@@ -84,27 +100,34 @@ describe Jat do
|
|
84
100
|
attribute = jat_class.attribute :foo
|
85
101
|
assert_equal jat_class.attributes[:foo], attribute
|
86
102
|
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe ".relationship" do
|
106
|
+
it "forces using of :serializer option" do
|
107
|
+
error = assert_raises(ArgumentError) { jat_class.relationship(:foo) }
|
108
|
+
assert_match "serializer", error.message
|
109
|
+
end
|
87
110
|
|
88
|
-
it "adds
|
89
|
-
jat_class.
|
90
|
-
|
111
|
+
it "adds new attribute" do
|
112
|
+
jat_class.relationship(:foo, serializer: jat_class)
|
113
|
+
|
114
|
+
attribute = jat_class.attributes[:foo]
|
115
|
+
assert_equal jat_class, attribute.serializer
|
91
116
|
end
|
92
117
|
end
|
93
118
|
|
94
119
|
describe "#initialize" do
|
95
|
-
it "initializes
|
96
|
-
jat = jat_class.new("
|
97
|
-
|
98
|
-
assert_equal "obj", jat.object
|
120
|
+
it "initializes context" do
|
121
|
+
jat = jat_class.new("context")
|
99
122
|
assert_equal "context", jat.context
|
100
123
|
end
|
101
124
|
end
|
102
125
|
|
103
126
|
describe "#to_h" do
|
104
127
|
it "raises error" do
|
105
|
-
jat = jat_class.new
|
128
|
+
jat = jat_class.new
|
106
129
|
|
107
|
-
error = assert_raises(Jat::Error) { jat.to_h }
|
130
|
+
error = assert_raises(Jat::Error) { jat.to_h(nil) }
|
108
131
|
error_message = "Method #to_h must be implemented by plugin"
|
109
132
|
assert_equal error_message, error.message
|
110
133
|
end
|
@@ -112,7 +135,7 @@ describe Jat do
|
|
112
135
|
|
113
136
|
describe "#config" do
|
114
137
|
it "returns self class config" do
|
115
|
-
jat = jat_class.new
|
138
|
+
jat = jat_class.new
|
116
139
|
|
117
140
|
assert_same jat.config, jat_class.config
|
118
141
|
end
|
data/test/lib/plugin_test.rb
CHANGED
@@ -6,7 +6,7 @@ require "test_plugin"
|
|
6
6
|
describe "plugin system" do
|
7
7
|
describe "Jat.plugin" do
|
8
8
|
let(:jat_class) { Class.new(Jat) }
|
9
|
-
let(:components) { [jat_class, jat_class::Attribute, jat_class::Config
|
9
|
+
let(:components) { [jat_class, jat_class::Attribute, jat_class::Config] }
|
10
10
|
|
11
11
|
before do
|
12
12
|
components.each do |component|
|
@@ -36,12 +36,12 @@ describe "plugin system" do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "calls before_load before loading plugin" do
|
40
40
|
jat_class.plugin(TestPlugin)
|
41
41
|
assert_equal :foo, jat_class.config[:before_load]
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "calls after_load after loading plugin" do
|
45
45
|
jat_class.plugin(TestPlugin)
|
46
46
|
assert_equal :plugin_foo, jat_class.config[:after_load]
|
47
47
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
# ARGV is populated with all test file names when running `rake`
|
4
|
+
# ARGV is not populated when running `ruby -Itest {file}`
|
5
|
+
# ARGV is not populated when running test by `m` gem - `m {file}`
|
6
|
+
# ARGV is not populated when running tests by `m` gem with line number - `m {file}:{line_number}`
|
7
|
+
if ARGV.any?
|
8
|
+
require "simplecov"
|
9
|
+
SimpleCov.start
|
9
10
|
end
|
10
11
|
|
11
12
|
require "bundler/setup"
|
data/test/test_plugin.rb
CHANGED
@@ -5,6 +5,15 @@ module TestPlugin
|
|
5
5
|
jat_class.config[:before_load] = jat_class.foo
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.load(jat_class, **_opts)
|
9
|
+
jat_class.extend(ClassMethods)
|
10
|
+
jat_class.include(InstanceMethods)
|
11
|
+
jat_class::Attribute.extend(AttributeClassMethods)
|
12
|
+
jat_class::Attribute.include(AttributeMethods)
|
13
|
+
jat_class::Config.extend(ConfigClassMethods)
|
14
|
+
jat_class::Config.include(ConfigMethods)
|
15
|
+
end
|
16
|
+
|
8
17
|
def self.after_load(jat_class, *)
|
9
18
|
jat_class.config[:after_load] = jat_class.foo
|
10
19
|
end
|
@@ -44,16 +53,4 @@ module TestPlugin
|
|
44
53
|
:plugin_foo
|
45
54
|
end
|
46
55
|
end
|
47
|
-
|
48
|
-
module PresenterClassMethods
|
49
|
-
def foo
|
50
|
-
:plugin_foo
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
module PresenterMethods
|
55
|
-
def foo
|
56
|
-
:plugin_foo
|
57
|
-
end
|
58
|
-
end
|
59
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Glushkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -53,47 +53,47 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.21'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.21'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: standard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
75
|
+
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activerecord
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '7.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '7.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sqlite3
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,31 +109,28 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.4'
|
111
111
|
description: |
|
112
|
-
|
113
|
-
Besides, it
|
112
|
+
JAT serializer allows you to generate a JSON response based on the fields requested by the client.
|
113
|
+
Besides, it helps to preload relations to avoid N+1 when used with activerecord.
|
114
114
|
email: aglushkov@shakuro.com
|
115
115
|
executables: []
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
-
- CHANGELOG.md
|
120
|
-
- README.md
|
121
|
-
- jat.gemspec
|
122
119
|
- lib/jat.rb
|
123
120
|
- lib/jat/attribute.rb
|
124
121
|
- lib/jat/config.rb
|
125
122
|
- lib/jat/plugins.rb
|
126
|
-
- lib/jat/plugins/
|
127
|
-
- lib/jat/plugins/
|
128
|
-
- lib/jat/plugins/
|
129
|
-
- lib/jat/plugins/
|
130
|
-
- lib/jat/plugins/
|
131
|
-
- lib/jat/plugins/
|
132
|
-
- lib/jat/plugins/
|
123
|
+
- lib/jat/plugins/activerecord/activerecord.rb
|
124
|
+
- lib/jat/plugins/base/base_activerecord_preloads/base_activerecord_preloads.rb
|
125
|
+
- lib/jat/plugins/base/base_activerecord_preloads/lib/preloader.rb
|
126
|
+
- lib/jat/plugins/base/base_lower_camel_case/base_lower_camel_case.rb
|
127
|
+
- lib/jat/plugins/base/base_preloads/base_preloads.rb
|
128
|
+
- lib/jat/plugins/base/base_preloads/lib/format_user_preloads.rb
|
129
|
+
- lib/jat/plugins/base/base_preloads/lib/preloads_with_path.rb
|
133
130
|
- lib/jat/plugins/cache/cache.rb
|
134
|
-
- lib/jat/plugins/camel_lower/camel_lower.rb
|
135
131
|
- lib/jat/plugins/json_api/json_api.rb
|
136
|
-
- lib/jat/plugins/json_api/lib/
|
132
|
+
- lib/jat/plugins/json_api/lib/fields_param_parser.rb
|
133
|
+
- lib/jat/plugins/json_api/lib/include_param_parser.rb
|
137
134
|
- lib/jat/plugins/json_api/lib/map.rb
|
138
135
|
- lib/jat/plugins/json_api/lib/params/fields.rb
|
139
136
|
- lib/jat/plugins/json_api/lib/params/fields/parse.rb
|
@@ -141,60 +138,78 @@ files:
|
|
141
138
|
- lib/jat/plugins/json_api/lib/params/include.rb
|
142
139
|
- lib/jat/plugins/json_api/lib/params/include/parse.rb
|
143
140
|
- lib/jat/plugins/json_api/lib/params/include/validate.rb
|
144
|
-
- lib/jat/plugins/json_api/lib/presenters/document_links_presenter.rb
|
145
|
-
- lib/jat/plugins/json_api/lib/presenters/document_meta_presenter.rb
|
146
|
-
- lib/jat/plugins/json_api/lib/presenters/jsonapi_presenter.rb
|
147
|
-
- lib/jat/plugins/json_api/lib/presenters/links_presenter.rb
|
148
|
-
- lib/jat/plugins/json_api/lib/presenters/meta_presenter.rb
|
149
|
-
- lib/jat/plugins/json_api/lib/presenters/relationship_links_presenter.rb
|
150
|
-
- lib/jat/plugins/json_api/lib/presenters/relationship_meta_presenter.rb
|
151
141
|
- lib/jat/plugins/json_api/lib/response.rb
|
152
|
-
- lib/jat/plugins/json_api/lib/
|
153
|
-
- lib/jat/plugins/
|
142
|
+
- lib/jat/plugins/json_api/lib/response_piece.rb
|
143
|
+
- lib/jat/plugins/json_api/plugins/json_api_activerecord/json_api_activerecord.rb
|
144
|
+
- lib/jat/plugins/json_api/plugins/json_api_lower_camel_case/json_api_lower_camel_case.rb
|
145
|
+
- lib/jat/plugins/json_api/plugins/json_api_maps_cache/json_api_maps_cache.rb
|
146
|
+
- lib/jat/plugins/json_api/plugins/json_api_preloads/json_api_preloads.rb
|
147
|
+
- lib/jat/plugins/json_api/plugins/json_api_preloads/lib/preloads.rb
|
148
|
+
- lib/jat/plugins/json_api/plugins/json_api_validate_params/json_api_validate_params.rb
|
149
|
+
- lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/params_error.rb
|
150
|
+
- lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb
|
151
|
+
- lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_include_param.rb
|
152
|
+
- lib/jat/plugins/lower_camel_case/lower_camel_case.rb
|
153
|
+
- lib/jat/plugins/maps_cache/maps_cache.rb
|
154
|
+
- lib/jat/plugins/preloads/preloads.rb
|
155
|
+
- lib/jat/plugins/simple_api/lib/fields_param_parser.rb
|
154
156
|
- lib/jat/plugins/simple_api/lib/map.rb
|
155
|
-
- lib/jat/plugins/simple_api/lib/params/parse.rb
|
156
157
|
- lib/jat/plugins/simple_api/lib/response.rb
|
158
|
+
- lib/jat/plugins/simple_api/lib/response_piece.rb
|
159
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_activerecord/simple_api_activerecord.rb
|
160
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_lower_camel_case/simple_api_lower_camel_case.rb
|
161
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_maps_cache/simple_api_maps_cache.rb
|
162
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_preloads/lib/preloads.rb
|
163
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_preloads/simple_api_preloads.rb
|
164
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_validate_params/lib/fields_error.rb
|
165
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_validate_params/lib/validate_fields_param.rb
|
166
|
+
- lib/jat/plugins/simple_api/plugins/simple_api_validate_params/simple_api_validate_params.rb
|
157
167
|
- lib/jat/plugins/simple_api/simple_api.rb
|
158
168
|
- lib/jat/plugins/to_str/to_str.rb
|
159
|
-
- lib/jat/
|
169
|
+
- lib/jat/plugins/types/types.rb
|
170
|
+
- lib/jat/plugins/validate_params/validate_params.rb
|
160
171
|
- lib/jat/utils/enum_deep_dup.rb
|
161
172
|
- lib/jat/utils/enum_deep_freeze.rb
|
162
173
|
- test/lib/jat/attribute_test.rb
|
163
174
|
- test/lib/jat/config_test.rb
|
164
|
-
- test/lib/jat/plugins/
|
165
|
-
- test/lib/jat/plugins/
|
166
|
-
- test/lib/jat/plugins/
|
167
|
-
- test/lib/jat/plugins/
|
168
|
-
- test/lib/jat/plugins/
|
169
|
-
- test/lib/jat/plugins/
|
170
|
-
- test/lib/jat/plugins/
|
175
|
+
- test/lib/jat/plugins/activerecord/activerecord_test.rb
|
176
|
+
- test/lib/jat/plugins/base_activerecord_preloads/base_activerecord_preloads_test.rb
|
177
|
+
- test/lib/jat/plugins/base_activerecord_preloads/lib/preloader_test.rb
|
178
|
+
- test/lib/jat/plugins/base_lower_camel_case/base_lower_camel_case_test.rb
|
179
|
+
- test/lib/jat/plugins/base_preloads/base_preloads_test.rb
|
180
|
+
- test/lib/jat/plugins/base_preloads/lib/format_user_preloads_test.rb
|
181
|
+
- test/lib/jat/plugins/base_preloads/lib/preloads_with_path_test.rb
|
171
182
|
- test/lib/jat/plugins/cache/cache_test.rb
|
172
|
-
- test/lib/jat/plugins/camel_lower/camel_lower_test.rb
|
173
183
|
- test/lib/jat/plugins/json_api/json_api_test.rb
|
174
|
-
- test/lib/jat/plugins/json_api/lib/
|
184
|
+
- test/lib/jat/plugins/json_api/lib/fields_param_parser_test.rb
|
185
|
+
- test/lib/jat/plugins/json_api/lib/include_param_parser_test.rb
|
175
186
|
- test/lib/jat/plugins/json_api/lib/map_test.rb
|
176
|
-
- test/lib/jat/plugins/json_api/lib/
|
177
|
-
- test/lib/jat/plugins/json_api/lib/params/fields/validate_test.rb
|
178
|
-
- test/lib/jat/plugins/json_api/lib/params/fields_test.rb
|
179
|
-
- test/lib/jat/plugins/json_api/lib/params/include/parse_test.rb
|
180
|
-
- test/lib/jat/plugins/json_api/lib/params/include/validate_test.rb
|
181
|
-
- test/lib/jat/plugins/json_api/lib/params/include_test.rb
|
182
|
-
- test/lib/jat/plugins/json_api/lib/presenters/document_links_presenter_test.rb
|
183
|
-
- test/lib/jat/plugins/json_api/lib/presenters/document_meta_presenter_test.rb
|
184
|
-
- test/lib/jat/plugins/json_api/lib/presenters/jsonapi_presenter_test.rb
|
185
|
-
- test/lib/jat/plugins/json_api/lib/presenters/links_presenter_test.rb
|
186
|
-
- test/lib/jat/plugins/json_api/lib/presenters/meta_presenter_test.rb
|
187
|
-
- test/lib/jat/plugins/json_api/lib/presenters/relationship_links_presenter_test.rb
|
188
|
-
- test/lib/jat/plugins/json_api/lib/presenters/relationship_meta_presenter_test.rb
|
187
|
+
- test/lib/jat/plugins/json_api/lib/response_piece_test.rb
|
189
188
|
- test/lib/jat/plugins/json_api/lib/response_test.rb
|
190
|
-
- test/lib/jat/plugins/
|
191
|
-
- test/lib/jat/plugins/
|
189
|
+
- test/lib/jat/plugins/json_api_activerecord/json_api_activerecord_test.rb
|
190
|
+
- test/lib/jat/plugins/json_api_lower_camel_case/json_api_lower_camel_case_test.rb
|
191
|
+
- test/lib/jat/plugins/json_api_maps_cache/json_api_maps_cache_test.rb
|
192
|
+
- test/lib/jat/plugins/json_api_preloads/json_api_preloads_test.rb
|
193
|
+
- test/lib/jat/plugins/json_api_preloads/lib/preloads_test.rb
|
194
|
+
- test/lib/jat/plugins/json_api_validate_params/json_api_validate_params_test.rb
|
195
|
+
- test/lib/jat/plugins/lower_camel_case/lower_camel_case_test.rb
|
196
|
+
- test/lib/jat/plugins/maps_cache/maps_cache_test.rb
|
197
|
+
- test/lib/jat/plugins/preloads/preloads_test.rb
|
198
|
+
- test/lib/jat/plugins/simple_api/lib/fields_param_parser_test.rb
|
192
199
|
- test/lib/jat/plugins/simple_api/lib/map_test.rb
|
193
|
-
- test/lib/jat/plugins/simple_api/lib/
|
200
|
+
- test/lib/jat/plugins/simple_api/lib/response_piece_test.rb
|
194
201
|
- test/lib/jat/plugins/simple_api/lib/response_test.rb
|
195
202
|
- test/lib/jat/plugins/simple_api/simple_api_test.rb
|
203
|
+
- test/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord_test.rb
|
204
|
+
- test/lib/jat/plugins/simple_api_lower_camel_case/simple_api_lower_camel_case_test.rb
|
205
|
+
- test/lib/jat/plugins/simple_api_maps_cache/simple_api_maps_cache_test.rb
|
206
|
+
- test/lib/jat/plugins/simple_api_preloads/lib/preloads_test.rb
|
207
|
+
- test/lib/jat/plugins/simple_api_preloads/simple_api_preloads_test.rb
|
208
|
+
- test/lib/jat/plugins/simple_api_validate_params/simple_api_validate_params_test.rb
|
196
209
|
- test/lib/jat/plugins/to_str/to_str_test.rb
|
197
|
-
- test/lib/jat/
|
210
|
+
- test/lib/jat/plugins/types/types_test.rb
|
211
|
+
- test/lib/jat/plugins/validate_params/validate_params_test.rb
|
212
|
+
- test/lib/jat/plugins_test.rb
|
198
213
|
- test/lib/jat/utils/enum_deep_dup_test.rb
|
199
214
|
- test/lib/jat/utils/enum_deep_freeze_test.rb
|
200
215
|
- test/lib/jat_test.rb
|
@@ -224,47 +239,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
239
|
- !ruby/object:Gem::Version
|
225
240
|
version: '0'
|
226
241
|
requirements: []
|
227
|
-
rubygems_version: 3.2.
|
242
|
+
rubygems_version: 3.2.22
|
228
243
|
signing_key:
|
229
244
|
specification_version: 4
|
230
245
|
summary: JSON API TOOLKIT
|
231
246
|
test_files:
|
232
247
|
- test/lib/jat/attribute_test.rb
|
233
248
|
- test/lib/jat/config_test.rb
|
234
|
-
- test/lib/jat/plugins/
|
235
|
-
- test/lib/jat/plugins/
|
236
|
-
- test/lib/jat/plugins/
|
237
|
-
- test/lib/jat/plugins/
|
238
|
-
- test/lib/jat/plugins/
|
239
|
-
- test/lib/jat/plugins/
|
240
|
-
- test/lib/jat/plugins/
|
249
|
+
- test/lib/jat/plugins/activerecord/activerecord_test.rb
|
250
|
+
- test/lib/jat/plugins/base_activerecord_preloads/base_activerecord_preloads_test.rb
|
251
|
+
- test/lib/jat/plugins/base_activerecord_preloads/lib/preloader_test.rb
|
252
|
+
- test/lib/jat/plugins/base_lower_camel_case/base_lower_camel_case_test.rb
|
253
|
+
- test/lib/jat/plugins/base_preloads/base_preloads_test.rb
|
254
|
+
- test/lib/jat/plugins/base_preloads/lib/format_user_preloads_test.rb
|
255
|
+
- test/lib/jat/plugins/base_preloads/lib/preloads_with_path_test.rb
|
241
256
|
- test/lib/jat/plugins/cache/cache_test.rb
|
242
|
-
- test/lib/jat/plugins/camel_lower/camel_lower_test.rb
|
243
257
|
- test/lib/jat/plugins/json_api/json_api_test.rb
|
244
|
-
- test/lib/jat/plugins/json_api/lib/
|
258
|
+
- test/lib/jat/plugins/json_api/lib/fields_param_parser_test.rb
|
259
|
+
- test/lib/jat/plugins/json_api/lib/include_param_parser_test.rb
|
245
260
|
- test/lib/jat/plugins/json_api/lib/map_test.rb
|
246
|
-
- test/lib/jat/plugins/json_api/lib/
|
247
|
-
- test/lib/jat/plugins/json_api/lib/params/fields/validate_test.rb
|
248
|
-
- test/lib/jat/plugins/json_api/lib/params/fields_test.rb
|
249
|
-
- test/lib/jat/plugins/json_api/lib/params/include/parse_test.rb
|
250
|
-
- test/lib/jat/plugins/json_api/lib/params/include/validate_test.rb
|
251
|
-
- test/lib/jat/plugins/json_api/lib/params/include_test.rb
|
252
|
-
- test/lib/jat/plugins/json_api/lib/presenters/document_links_presenter_test.rb
|
253
|
-
- test/lib/jat/plugins/json_api/lib/presenters/document_meta_presenter_test.rb
|
254
|
-
- test/lib/jat/plugins/json_api/lib/presenters/jsonapi_presenter_test.rb
|
255
|
-
- test/lib/jat/plugins/json_api/lib/presenters/links_presenter_test.rb
|
256
|
-
- test/lib/jat/plugins/json_api/lib/presenters/meta_presenter_test.rb
|
257
|
-
- test/lib/jat/plugins/json_api/lib/presenters/relationship_links_presenter_test.rb
|
258
|
-
- test/lib/jat/plugins/json_api/lib/presenters/relationship_meta_presenter_test.rb
|
261
|
+
- test/lib/jat/plugins/json_api/lib/response_piece_test.rb
|
259
262
|
- test/lib/jat/plugins/json_api/lib/response_test.rb
|
260
|
-
- test/lib/jat/plugins/
|
261
|
-
- test/lib/jat/plugins/
|
263
|
+
- test/lib/jat/plugins/json_api_activerecord/json_api_activerecord_test.rb
|
264
|
+
- test/lib/jat/plugins/json_api_lower_camel_case/json_api_lower_camel_case_test.rb
|
265
|
+
- test/lib/jat/plugins/json_api_maps_cache/json_api_maps_cache_test.rb
|
266
|
+
- test/lib/jat/plugins/json_api_preloads/json_api_preloads_test.rb
|
267
|
+
- test/lib/jat/plugins/json_api_preloads/lib/preloads_test.rb
|
268
|
+
- test/lib/jat/plugins/json_api_validate_params/json_api_validate_params_test.rb
|
269
|
+
- test/lib/jat/plugins/lower_camel_case/lower_camel_case_test.rb
|
270
|
+
- test/lib/jat/plugins/maps_cache/maps_cache_test.rb
|
271
|
+
- test/lib/jat/plugins/preloads/preloads_test.rb
|
272
|
+
- test/lib/jat/plugins/simple_api/lib/fields_param_parser_test.rb
|
262
273
|
- test/lib/jat/plugins/simple_api/lib/map_test.rb
|
263
|
-
- test/lib/jat/plugins/simple_api/lib/
|
274
|
+
- test/lib/jat/plugins/simple_api/lib/response_piece_test.rb
|
264
275
|
- test/lib/jat/plugins/simple_api/lib/response_test.rb
|
265
276
|
- test/lib/jat/plugins/simple_api/simple_api_test.rb
|
277
|
+
- test/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord_test.rb
|
278
|
+
- test/lib/jat/plugins/simple_api_lower_camel_case/simple_api_lower_camel_case_test.rb
|
279
|
+
- test/lib/jat/plugins/simple_api_maps_cache/simple_api_maps_cache_test.rb
|
280
|
+
- test/lib/jat/plugins/simple_api_preloads/lib/preloads_test.rb
|
281
|
+
- test/lib/jat/plugins/simple_api_preloads/simple_api_preloads_test.rb
|
282
|
+
- test/lib/jat/plugins/simple_api_validate_params/simple_api_validate_params_test.rb
|
266
283
|
- test/lib/jat/plugins/to_str/to_str_test.rb
|
267
|
-
- test/lib/jat/
|
284
|
+
- test/lib/jat/plugins/types/types_test.rb
|
285
|
+
- test/lib/jat/plugins/validate_params/validate_params_test.rb
|
286
|
+
- test/lib/jat/plugins_test.rb
|
268
287
|
- test/lib/jat/utils/enum_deep_dup_test.rb
|
269
288
|
- test/lib/jat/utils/enum_deep_freeze_test.rb
|
270
289
|
- test/lib/jat_test.rb
|
data/CHANGELOG.md
DELETED
data/README.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# JAT (JSON API TOOLKIT)
|
2
|
-
|
3
|
-
JAT helps to serialize complex nested objects to JSON format.
|
4
|
-
|
5
|
-
Key features:
|
6
|
-
|
7
|
-
* **Auto preload** – No need to preload data manually to omit N+1 (Active Record only)
|
8
|
-
* **Configurable exposed attributes** – No more tons of serializers with different attributes sets
|
9
|
-
* **Modular design** – plugin system (aka [shrine]) allows you to load only the functionality you need
|
10
|
-
|
11
|
-
## Output Format
|
12
|
-
|
13
|
-
Supported two serialization formats:
|
14
|
-
- [JSON:API]
|
15
|
-
- Simple nested JSON objects (same as good old [AMS] or [Jbuilder])
|
16
|
-
|
17
|
-
|
18
|
-
[shrine]: https://shrinerb.com/docs/getting-started#plugin-system
|
19
|
-
[JSON:API]: https://jsonapi.org/format/
|
20
|
-
[AMS]: https://github.com/rails-api/active_model_serializers/tree/0-9-stable
|
21
|
-
[Jbuilder]: https://github.com/rails/jbuilder
|
data/jat.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Gem::Specification.new do |gem|
|
4
|
-
gem.name = "jat"
|
5
|
-
gem.version = "0.0.3"
|
6
|
-
gem.summary = "JSON API TOOLKIT"
|
7
|
-
gem.description = <<~DESC
|
8
|
-
The JAT serializer allows you to generate a JSON response based on the fields requested by the client.
|
9
|
-
Besides, it avoids manually adding includes and solves N+1 problems on its own.
|
10
|
-
DESC
|
11
|
-
|
12
|
-
gem.authors = ["Andrey Glushkov"]
|
13
|
-
gem.email = "aglushkov@shakuro.com"
|
14
|
-
gem.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*.rb", "jat.gemspec", "doc/**/*.md"]
|
15
|
-
gem.test_files = `git ls-files -- test/*`.split("\n")
|
16
|
-
gem.homepage = "https://github.com/aglushkov/jat"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.required_ruby_version = 2.5
|
19
|
-
gem.metadata = {
|
20
|
-
"bug_tracker_uri" => "https://github.com/aglushkov/jat/issues",
|
21
|
-
"changelog_uri" => "https://github.com/aglushkov/jat/blob/master/CHANGELOG.md",
|
22
|
-
"source_code_uri" => "https://github.com/aglushkov/jat"
|
23
|
-
}
|
24
|
-
|
25
|
-
# General testing helpers
|
26
|
-
gem.add_development_dependency "minitest", "~> 5.14"
|
27
|
-
gem.add_development_dependency "mocha", "~> 1.12"
|
28
|
-
gem.add_development_dependency "rake", "~> 13.0"
|
29
|
-
|
30
|
-
# Code standard
|
31
|
-
gem.add_development_dependency "standard", "~> 1.0"
|
32
|
-
gem.add_development_dependency "simplecov", "~> 0.21"
|
33
|
-
|
34
|
-
# ORM plugins
|
35
|
-
gem.add_development_dependency "activerecord", RUBY_VERSION >= "2.5" ? "~> 6.0" : "~> 5.2"
|
36
|
-
gem.add_development_dependency "sqlite3", "~> 1.4" unless RUBY_ENGINE == "jruby"
|
37
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "./lib/preloader"
|
4
|
-
|
5
|
-
class Jat
|
6
|
-
module Plugins
|
7
|
-
module ActiverecordPreloads
|
8
|
-
module InstanceMethods
|
9
|
-
def initialize(*)
|
10
|
-
super
|
11
|
-
@object = add_preloads(@object)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def add_preloads(obj)
|
17
|
-
return obj if obj.nil? || (obj.is_a?(Array) && obj.empty?)
|
18
|
-
|
19
|
-
preloads = self.class.jat_preloads(self)
|
20
|
-
return obj if preloads.empty?
|
21
|
-
|
22
|
-
Preloader.preload(obj, preloads)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
register_plugin(:_activerecord_preloads, ActiverecordPreloads)
|
28
|
-
end
|
29
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "./lib/preloads"
|
4
|
-
|
5
|
-
class Jat
|
6
|
-
module Plugins
|
7
|
-
module JsonApiActiverecord
|
8
|
-
def self.after_load(jat_class, **opts)
|
9
|
-
jat_class.plugin :_preloads, **opts
|
10
|
-
jat_class.plugin :_activerecord_preloads, **opts
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def jat_preloads(jat)
|
15
|
-
Preloads.call(jat)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
register_plugin(:_json_api_activerecord, JsonApiActiverecord)
|
21
|
-
end
|
22
|
-
end
|