rails_json_serializer 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/serializer/concern.rb +12 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6b2c3e2e7b905079dce0ddbbf0b48028a36d68b10da5ab4278d597eaf70713a
4
- data.tar.gz: 9e730e031d3b73eaa9fb27f838fb4f6761256755281257cb99db9b3b15659ded
3
+ metadata.gz: dc8a9ac788966e52d712b4927d9ec959015aeec7c401ed04741d34faeb315786
4
+ data.tar.gz: 2ef1b797adfa346886d437cd8b5322418ddd96d1f06f1bf80d68bf59f9d589e6
5
5
  SHA512:
6
- metadata.gz: 70bba5bd544d0d2e95ae9bec6b5c4762eec9b036fe750a0777ef7663903b9894e05f8c2fcb703f2d021023594132ab2d6d6cecea4a1d8e2c12a3b72dd1c1d7e2
7
- data.tar.gz: 27594e6cb05baefffd863555b226f2b672a3c84dcebbb661672266cba0ede47181efe39e702b7a44872582b0a873d5957e91200b4e8a1c6ef34aaf3f76abba98
6
+ metadata.gz: 66ee9df244dd1e8317aab9013fe4ae6dc83dd77963660c8700e268f70bcb795b907299b88a1b5b1b7259ff663b5200122eda6a75d2a6d78763b6530e87ffb285
7
+ data.tar.gz: 5923bb6172eb2a3bd8306035517cee75c975bbc6f2e4fa49922ccf206ef7042115377365f30887550a89f2e55905bc5623aa04975dd98daebcf681161d03d881
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_json_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - benjamin.dana.software.dev@gmail.com