rails_json_serializer 1.1.4 → 1.2.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/lib/serializer/concern.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc8a9ac788966e52d712b4927d9ec959015aeec7c401ed04741d34faeb315786
|
4
|
+
data.tar.gz: 2ef1b797adfa346886d437cd8b5322418ddd96d1f06f1bf80d68bf59f9d589e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66ee9df244dd1e8317aab9013fe4ae6dc83dd77963660c8700e268f70bcb795b907299b88a1b5b1b7259ff663b5200122eda6a75d2a6d78763b6530e87ffb285
|
7
|
+
data.tar.gz: 5923bb6172eb2a3bd8306035517cee75c975bbc6f2e4fa49922ccf206ef7042115377365f30887550a89f2e55905bc5623aa04975dd98daebcf681161d03d881
|
data/lib/serializer/concern.rb
CHANGED
@@ -213,6 +213,7 @@ module Serializer
|
|
213
213
|
klass = self if klass.nil?
|
214
214
|
if options[:include].present? && !options[:skip_eager_loading]
|
215
215
|
options[:include].each do |include_key, include_hash|
|
216
|
+
next if include_hash[:skip_eager_loading] == true
|
216
217
|
# Will 'next' if there is a scope that takes arguments, an instance-dependent scope.
|
217
218
|
# Can't eager load when assocation has a instance condition for it's associative scope.
|
218
219
|
# Might not be a real assocation
|
@@ -223,6 +224,17 @@ module Serializer
|
|
223
224
|
query_filter[include_key] = generate_includes_from_json_query(include_hash, klass.reflect_on_association(include_key).klass)
|
224
225
|
end
|
225
226
|
end
|
227
|
+
# Does not include data, just eager-loads. Useful when methods need assocations, but you don't need association data.
|
228
|
+
if options[:eager_include].present?
|
229
|
+
options[:eager_include].each do |include_key|
|
230
|
+
# Will 'next' if there is a scope that takes arguments, an instance-dependent scope.
|
231
|
+
# Can't eager load when assocation has a instance condition for it's associative scope.
|
232
|
+
# Might not be a real assocation
|
233
|
+
next if klass.reflect_on_association(include_key).nil?
|
234
|
+
next if klass.reflect_on_association(include_key).scope&.arity&.nonzero?
|
235
|
+
query_filter[include_key] ||= {}
|
236
|
+
end
|
237
|
+
end
|
226
238
|
return query_filter
|
227
239
|
end
|
228
240
|
# END MODEL CLASS METHODS
|