jsonapi_compliable 0.11.34 → 1.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -2
  4. data/Rakefile +7 -3
  5. data/jsonapi_compliable.gemspec +7 -3
  6. data/lib/generators/jsonapi/resource_generator.rb +8 -79
  7. data/lib/generators/jsonapi/templates/application_resource.rb.erb +2 -1
  8. data/lib/generators/jsonapi/templates/controller.rb.erb +19 -64
  9. data/lib/generators/jsonapi/templates/resource.rb.erb +5 -47
  10. data/lib/generators/jsonapi/templates/resource_reads_spec.rb.erb +62 -0
  11. data/lib/generators/jsonapi/templates/resource_writes_spec.rb.erb +63 -0
  12. data/lib/jsonapi_compliable.rb +87 -18
  13. data/lib/jsonapi_compliable/adapters/abstract.rb +202 -45
  14. data/lib/jsonapi_compliable/adapters/active_record.rb +6 -130
  15. data/lib/jsonapi_compliable/adapters/active_record/base.rb +247 -0
  16. data/lib/jsonapi_compliable/adapters/active_record/belongs_to_sideload.rb +17 -0
  17. data/lib/jsonapi_compliable/adapters/active_record/has_many_sideload.rb +17 -0
  18. data/lib/jsonapi_compliable/adapters/active_record/has_one_sideload.rb +17 -0
  19. data/lib/jsonapi_compliable/adapters/active_record/inferrence.rb +12 -0
  20. data/lib/jsonapi_compliable/adapters/active_record/many_to_many_sideload.rb +30 -0
  21. data/lib/jsonapi_compliable/adapters/null.rb +177 -6
  22. data/lib/jsonapi_compliable/base.rb +33 -320
  23. data/lib/jsonapi_compliable/context.rb +16 -0
  24. data/lib/jsonapi_compliable/deserializer.rb +14 -39
  25. data/lib/jsonapi_compliable/errors.rb +227 -24
  26. data/lib/jsonapi_compliable/extensions/extra_attribute.rb +3 -1
  27. data/lib/jsonapi_compliable/filter_operators.rb +25 -0
  28. data/lib/jsonapi_compliable/hash_renderer.rb +57 -0
  29. data/lib/jsonapi_compliable/query.rb +190 -202
  30. data/lib/jsonapi_compliable/rails.rb +12 -6
  31. data/lib/jsonapi_compliable/railtie.rb +64 -0
  32. data/lib/jsonapi_compliable/renderer.rb +60 -0
  33. data/lib/jsonapi_compliable/resource.rb +35 -663
  34. data/lib/jsonapi_compliable/resource/configuration.rb +239 -0
  35. data/lib/jsonapi_compliable/resource/dsl.rb +138 -0
  36. data/lib/jsonapi_compliable/resource/interface.rb +32 -0
  37. data/lib/jsonapi_compliable/resource/polymorphism.rb +68 -0
  38. data/lib/jsonapi_compliable/resource/sideloading.rb +102 -0
  39. data/lib/jsonapi_compliable/resource_proxy.rb +127 -0
  40. data/lib/jsonapi_compliable/responders.rb +19 -0
  41. data/lib/jsonapi_compliable/runner.rb +25 -0
  42. data/lib/jsonapi_compliable/scope.rb +37 -79
  43. data/lib/jsonapi_compliable/scoping/extra_attributes.rb +29 -0
  44. data/lib/jsonapi_compliable/scoping/filter.rb +39 -58
  45. data/lib/jsonapi_compliable/scoping/filterable.rb +9 -14
  46. data/lib/jsonapi_compliable/scoping/paginate.rb +9 -3
  47. data/lib/jsonapi_compliable/scoping/sort.rb +16 -4
  48. data/lib/jsonapi_compliable/sideload.rb +221 -347
  49. data/lib/jsonapi_compliable/sideload/belongs_to.rb +34 -0
  50. data/lib/jsonapi_compliable/sideload/has_many.rb +16 -0
  51. data/lib/jsonapi_compliable/sideload/has_one.rb +9 -0
  52. data/lib/jsonapi_compliable/sideload/many_to_many.rb +24 -0
  53. data/lib/jsonapi_compliable/sideload/polymorphic_belongs_to.rb +108 -0
  54. data/lib/jsonapi_compliable/stats/payload.rb +4 -8
  55. data/lib/jsonapi_compliable/types.rb +172 -0
  56. data/lib/jsonapi_compliable/util/attribute_check.rb +88 -0
  57. data/lib/jsonapi_compliable/util/persistence.rb +29 -7
  58. data/lib/jsonapi_compliable/util/relationship_payload.rb +4 -4
  59. data/lib/jsonapi_compliable/util/render_options.rb +4 -32
  60. data/lib/jsonapi_compliable/util/serializer_attributes.rb +98 -0
  61. data/lib/jsonapi_compliable/util/validation_response.rb +15 -9
  62. data/lib/jsonapi_compliable/version.rb +1 -1
  63. metadata +105 -24
  64. data/lib/generators/jsonapi/field_generator.rb +0 -0
  65. data/lib/generators/jsonapi/templates/create_request_spec.rb.erb +0 -29
  66. data/lib/generators/jsonapi/templates/destroy_request_spec.rb.erb +0 -20
  67. data/lib/generators/jsonapi/templates/index_request_spec.rb.erb +0 -22
  68. data/lib/generators/jsonapi/templates/payload.rb.erb +0 -39
  69. data/lib/generators/jsonapi/templates/serializer.rb.erb +0 -25
  70. data/lib/generators/jsonapi/templates/show_request_spec.rb.erb +0 -19
  71. data/lib/generators/jsonapi/templates/update_request_spec.rb.erb +0 -33
  72. data/lib/jsonapi_compliable/adapters/active_record_sideloading.rb +0 -152
  73. data/lib/jsonapi_compliable/scoping/extra_fields.rb +0 -58
@@ -0,0 +1,63 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe <%= resource_klass %>, type: :resource do
4
+ describe 'creating' do
5
+ let(:payload) do
6
+ {
7
+ data: {
8
+ type: '<%= file_name.pluralize %>',
9
+ attributes: { }
10
+ }
11
+ }
12
+ end
13
+
14
+ let(:instance) do
15
+ <%= resource_klass %>.build(payload)
16
+ end
17
+
18
+ it 'works' do
19
+ expect {
20
+ expect(instance.save).to eq(true)
21
+ }.to change { <%= model_klass %>.count }.by(1)
22
+ end
23
+ end
24
+
25
+ describe 'updating' do
26
+ let!(:<%= file_name %>) { create(:<%= file_name %>) }
27
+
28
+ let(:payload) do
29
+ {
30
+ data: {
31
+ id: <%= file_name %>.id.to_s,
32
+ type: '<%= file_name.pluralize %>',
33
+ attributes: { } # Todo!
34
+ }
35
+ }
36
+ end
37
+
38
+ let(:instance) do
39
+ <%= resource_klass %>.find(payload)
40
+ end
41
+
42
+ xit 'works (add some attributes and enable this spec)' do
43
+ expect {
44
+ expect(instance.update_attributes).to eq(true)
45
+ }.to change { <%= file_name %>.reload.updated_at }
46
+ # and change { instance.foo }.to('bar') <- example
47
+ end
48
+ end
49
+
50
+ describe 'destroying' do
51
+ let!(:<%= file_name %>) { create(:<%= file_name %>) }
52
+
53
+ let(:instance) do
54
+ <%= resource_klass %>.find(id: <%= file_name %>.id)
55
+ end
56
+
57
+ it 'works' do
58
+ expect {
59
+ expect(instance.destroy).to eq(true)
60
+ }.to change { <%= model_klass %>.count }.by(-1)
61
+ end
62
+ end
63
+ end
@@ -1,20 +1,88 @@
1
+ require 'json'
2
+ require 'forwardable'
3
+ require 'active_support/core_ext/string'
4
+ require 'active_support/core_ext/class/attribute'
5
+ require 'active_support/core_ext/hash/conversions' # to_xml
6
+ require 'active_support/concern'
7
+ require 'active_support/time'
8
+
9
+ require 'dry-types'
10
+ require 'jsonapi_errorable'
11
+
12
+ require 'jsonapi/serializable'
13
+ # Temporary fix until fixed upstream
14
+ # https://github.com/jsonapi-rb/jsonapi-serializable/pull/102
15
+ JSONAPI::Serializable::Resource.class_eval do
16
+ def requested_relationships(fields)
17
+ @_relationships
18
+ end
19
+ end
20
+
21
+ # This library looks up a serializer based on the record's class name
22
+ # This wouldn't work for us, since a model may be associated with
23
+ # multiple resources.
24
+ # Instead, this variable is assigned when the query is resolved
25
+ # To ensure we always render with the *resource* serializer
26
+ JSONAPI::Serializable::Renderer.class_eval do
27
+ def _build(object, exposures, klass)
28
+ klass = object.instance_variable_get(:@__serializer_klass)
29
+ klass.new(exposures.merge(object: object))
30
+ end
31
+ end
32
+
33
+ # See above comment
34
+ JSONAPI::Serializable::Relationship.class_eval do
35
+ def data
36
+ @_resources_block = proc do
37
+ resources = yield
38
+ if resources.nil?
39
+ nil
40
+ elsif resources.respond_to?(:to_ary)
41
+ Array(resources).map do |obj|
42
+ klass = obj.instance_variable_get(:@__serializer_klass)
43
+ klass.new(@_exposures.merge(object: obj))
44
+ end
45
+ else
46
+ klass = resources.instance_variable_get(:@__serializer_klass)
47
+ klass.new(@_exposures.merge(object: resources))
48
+ end
49
+ end
50
+ end
51
+ end
52
+
1
53
  require "jsonapi_compliable/version"
2
54
  require "jsonapi_compliable/configuration"
55
+ require "jsonapi_compliable/context"
3
56
  require "jsonapi_compliable/errors"
57
+ require "jsonapi_compliable/types"
58
+ require "jsonapi_compliable/adapters/abstract"
59
+ require "jsonapi_compliable/resource/sideloading"
60
+ require "jsonapi_compliable/resource/configuration"
61
+ require "jsonapi_compliable/resource/dsl"
62
+ require "jsonapi_compliable/resource/interface"
63
+ require "jsonapi_compliable/resource/polymorphism"
64
+ require "jsonapi_compliable/sideload"
65
+ require "jsonapi_compliable/sideload/has_many"
66
+ require "jsonapi_compliable/sideload/belongs_to"
67
+ require "jsonapi_compliable/sideload/has_one"
68
+ require "jsonapi_compliable/sideload/many_to_many"
69
+ require "jsonapi_compliable/sideload/polymorphic_belongs_to"
4
70
  require "jsonapi_compliable/resource"
71
+ require "jsonapi_compliable/resource_proxy"
5
72
  require "jsonapi_compliable/query"
6
- require "jsonapi_compliable/sideload"
7
73
  require "jsonapi_compliable/scope"
8
74
  require "jsonapi_compliable/deserializer"
75
+ require "jsonapi_compliable/renderer"
76
+ require "jsonapi_compliable/hash_renderer"
77
+ require "jsonapi_compliable/filter_operators"
9
78
  require "jsonapi_compliable/scoping/base"
10
79
  require "jsonapi_compliable/scoping/sort"
11
80
  require "jsonapi_compliable/scoping/paginate"
12
- require "jsonapi_compliable/scoping/extra_fields"
81
+ require "jsonapi_compliable/scoping/extra_attributes"
13
82
  require "jsonapi_compliable/scoping/filterable"
14
83
  require "jsonapi_compliable/scoping/default_filter"
15
84
  require "jsonapi_compliable/scoping/filter"
16
85
  require "jsonapi_compliable/util/render_options"
17
- require "jsonapi_compliable/adapters/abstract"
18
86
  require "jsonapi_compliable/stats/dsl"
19
87
  require "jsonapi_compliable/stats/payload"
20
88
  require "jsonapi_compliable/util/include_params"
@@ -25,26 +93,25 @@ require "jsonapi_compliable/util/persistence"
25
93
  require "jsonapi_compliable/util/validation_response"
26
94
  require "jsonapi_compliable/util/sideload"
27
95
  require "jsonapi_compliable/util/hooks"
96
+ require "jsonapi_compliable/util/attribute_check"
97
+ require "jsonapi_compliable/util/serializer_attributes"
28
98
 
29
- # require correct jsonapi-rb before extensions
30
- if defined?(Rails)
31
- require 'jsonapi_compliable/rails'
32
- else
33
- require 'jsonapi/serializable'
34
- end
35
-
36
- # Temporary fix until fixed upstream
37
- # https://github.com/jsonapi-rb/jsonapi-serializable/pull/102
38
- JSONAPI::Serializable::Resource.class_eval do
39
- def requested_relationships(fields)
40
- @_relationships
41
- end
42
- end
99
+ require 'jsonapi_compliable/adapters/null'
43
100
 
44
101
  require "jsonapi_compliable/extensions/extra_attribute"
45
102
  require "jsonapi_compliable/extensions/boolean_attribute"
46
103
  require "jsonapi_compliable/extensions/temp_id"
47
104
 
105
+ if defined?(ActiveRecord)
106
+ require 'jsonapi_compliable/adapters/active_record'
107
+ end
108
+
109
+ if defined?(Rails)
110
+ require 'jsonapi_compliable/railtie'
111
+ require 'jsonapi_compliable/rails'
112
+ require 'jsonapi_compliable/responders'
113
+ end
114
+
48
115
  module JsonapiCompliable
49
116
  autoload :Base, 'jsonapi_compliable/base'
50
117
 
@@ -65,7 +132,7 @@ module JsonapiCompliable
65
132
  end
66
133
 
67
134
  # @api private
68
- def self.with_context(obj, namespace)
135
+ def self.with_context(obj, namespace = nil)
69
136
  begin
70
137
  prior = self.context
71
138
  self.context = { object: obj, namespace: namespace }
@@ -89,3 +156,5 @@ module JsonapiCompliable
89
156
  yield config
90
157
  end
91
158
  end
159
+
160
+ require "jsonapi_compliable/runner"
@@ -76,17 +76,184 @@ module JsonapiCompliable
76
76
  # @see Adapters::ActiveRecordSideloading
77
77
  # @see Adapters::Null
78
78
  class Abstract
79
- # @param scope The scope object we are chaining
80
- # @param [Symbol] attribute The attribute name we are filtering
81
- # @param value The corresponding query parameter value
82
- # @return the scope
83
- #
84
- # @example ActiveRecord default
85
- # def filter(scope, attribute, value)
86
- # scope.where(attribute => value)
87
- # end
88
- def filter(scope, attribute, value)
89
- raise 'you must override #filter in an adapter subclass'
79
+ def filter_string_eq(scope, attribute, value)
80
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_eq)
81
+ end
82
+
83
+ def filter_string_eql(scope, attribute, value)
84
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_eql)
85
+ end
86
+
87
+ def filter_string_not_eq(scope, attribute, value)
88
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_not_eq)
89
+ end
90
+
91
+ def filter_string_not_eql(scope, attribute, value)
92
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_not_eql)
93
+ end
94
+
95
+ def filter_string_prefix(scope, attribute, value)
96
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_prefix)
97
+ end
98
+
99
+ def filter_string_not_prefix(scope, attribute, value)
100
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_not_prefix)
101
+ end
102
+
103
+ def filter_string_suffix(scope, attribute, value)
104
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_suffix)
105
+ end
106
+
107
+ def filter_string_not_suffix(scope, attribute, value)
108
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_not_suffix)
109
+ end
110
+
111
+ def filter_string_like(scope, attribute, value)
112
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_like)
113
+ end
114
+
115
+ def filter_string_not_like(scope, attribute, value)
116
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_string_not_like)
117
+ end
118
+
119
+ def filter_integer_eq(scope, attribute, value)
120
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_integer_eq)
121
+ end
122
+
123
+ def filter_integer_not_eq(scope, attribute, value)
124
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_integer_not_eq)
125
+ end
126
+
127
+ def filter_integer_gt(scope, attribute, value)
128
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_integer_gt)
129
+ end
130
+
131
+ def filter_integer_gte(scope, attribute, value)
132
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_integer_gte)
133
+ end
134
+
135
+ def filter_integer_lt(scope, attribute, value)
136
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_integer_lt)
137
+ end
138
+
139
+ def filter_integer_lte(scope, attribute, value)
140
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_integer_lte)
141
+ end
142
+
143
+ def filter_datetime_eq(scope, attribute, value)
144
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_eq)
145
+ end
146
+
147
+ def filter_datetime_not_eq(scope, attribute, value)
148
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_not_eq)
149
+ end
150
+
151
+ def filter_datetime_lte(scope, attribute, value)
152
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_lte)
153
+ end
154
+
155
+ def filter_float_eq(scope, attribute, value)
156
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_float_eq)
157
+ end
158
+
159
+ def filter_float_not_eq(scope, attribute, value)
160
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_float_not_eq)
161
+ end
162
+
163
+ def filter_float_gt(scope, attribute, value)
164
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_float_gt)
165
+ end
166
+
167
+ def filter_float_gte(scope, attribute, value)
168
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_float_gte)
169
+ end
170
+
171
+ def filter_float_lt(scope, attribute, value)
172
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_float_lt)
173
+ end
174
+
175
+ def filter_float_lte(scope, attribute, value)
176
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_float_lte)
177
+ end
178
+
179
+ def filter_decimal_eq(scope, attribute, value)
180
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_decimal_eq)
181
+ end
182
+
183
+ def filter_decimal_not_eq(scope, attribute, value)
184
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_decimal_not_eq)
185
+ end
186
+
187
+ def filter_decimal_gt(scope, attribute, value)
188
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_decimal_gt)
189
+ end
190
+
191
+ def filter_decimal_gte(scope, attribute, value)
192
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_decimal_gte)
193
+ end
194
+
195
+ def filter_decimal_lt(scope, attribute, value)
196
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_decimal_lt)
197
+ end
198
+
199
+ def filter_decimal_lte(scope, attribute, value)
200
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_decimal_lte)
201
+ end
202
+
203
+ def filter_datetime_eq(scope, attribute, value)
204
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_eq)
205
+ end
206
+
207
+ def filter_datetime_not_eq(scope, attribute, value)
208
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_not_eq)
209
+ end
210
+
211
+ def filter_datetime_gt(scope, attribute, value)
212
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_gt)
213
+ end
214
+
215
+ def filter_datetime_gte(scope, attribute, value)
216
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_gte)
217
+ end
218
+
219
+ def filter_datetime_lt(scope, attribute, value)
220
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_lt)
221
+ end
222
+
223
+ def filter_datetime_lte(scope, attribute, value)
224
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_datetime_lte)
225
+ end
226
+
227
+ def filter_date_eq(scope, attribute, value)
228
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_date_eq)
229
+ end
230
+
231
+ def filter_date_not_eq(scope, attribute, value)
232
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_date_not_eq)
233
+ end
234
+
235
+ def filter_date_gt(scope, attribute, value)
236
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_date_gt)
237
+ end
238
+
239
+ def filter_date_gte(scope, attribute, value)
240
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_date_gte)
241
+ end
242
+
243
+ def filter_date_lt(scope, attribute, value)
244
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_date_lt)
245
+ end
246
+
247
+ def filter_date_lte(scope, attribute, value)
248
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_date_lte)
249
+ end
250
+
251
+ def filter_boolean_eq(scope, attribute, value)
252
+ raise Errors::AdapterNotImplemented.new(self, attribute, :filter_boolean_eq)
253
+ end
254
+
255
+ def base_scope(model)
256
+ raise 'you must override #base_scope in an adapter subclass'
90
257
  end
91
258
 
92
259
  # @param scope The scope object we are chaining
@@ -211,30 +378,19 @@ module JsonapiCompliable
211
378
  scope
212
379
  end
213
380
 
214
- # Assign these two objects together.
215
- #
216
- # @example Basic accessor
217
- # def associate(parent, child, association_name, association_type)
218
- # if association_type == :has_many
219
- # parent.send(association_name).push(child)
220
- # else
221
- # child.send(:"#{association_name}=", parent)
222
- # end
223
- # end
224
- #
225
- # +association_name+ and +association_type+ come from your sideload
226
- # configuration:
227
- #
228
- # allow_sideload :the_name, type: the_type do
229
- # # ... code.
230
- # end
231
- #
232
- # @param parent The parent object (via the JSONAPI 'relationships' graph)
233
- # @param child The child object (via the JSONAPI 'relationships' graph)
234
- # @param association_name The 'relationships' key we are processing
235
- # @param association_type The Sideload type (see Sideload#type). Usually :has_many/:belongs_to/etc
381
+ def associate_all(parent, children, association_name, association_type)
382
+ children.each do |c|
383
+ associate(parent, c, association_name, association_type)
384
+ end
385
+ end
386
+
387
+ # Probably want to override
236
388
  def associate(parent, child, association_name, association_type)
237
- raise 'you must override #associate in an adapter subclass'
389
+ if [:has_many, :many_to_many].include?(association_type)
390
+ parent.send(:"#{association_name}") << child
391
+ else
392
+ parent.send(:"#{association_name}=", child)
393
+ end
238
394
  end
239
395
 
240
396
  # Remove the association without destroying objects
@@ -277,17 +433,18 @@ module JsonapiCompliable
277
433
  raise 'you must override #disassociate in an adapter subclass'
278
434
  end
279
435
 
280
- # This module gets mixed in to Sideload classes
281
- # This is where you define methods like has_many,
282
- # belongs_to etc that wrap the lower-level Sideload#allow_sideload
283
- #
284
- # @see Resource#allow_sideload
285
- # @see Sideload#allow_sideload
286
- # @see Adapters::ActiveRecord#sideloading_module
287
- # @see Adapters::ActiveRecordSideloading
288
- # @return the module to mix in
289
- def sideloading_module
290
- Module.new
436
+ # You want to override this!
437
+ # Map of association_type => sideload_class
438
+ # e.g.
439
+ # { has_many: Adapters::ActiveRecord::HasManySideload }
440
+ def sideloading_classes
441
+ {
442
+ has_many: ::JsonapiCompliable::Sideload::HasMany,
443
+ belongs_to: ::JsonapiCompliable::Sideload::BelongsTo,
444
+ has_one: ::JsonapiCompliable::Sideload::HasOne,
445
+ many_to_many: ::JsonapiCompliable::Sideload::ManyToMany,
446
+ polymorphic_belongs_to: ::JsonapiCompliable::Sideload::PolymorphicBelongsTo
447
+ }
291
448
  end
292
449
 
293
450
  # @param [Class] model_class The configured model class (see Resource.model)