goldiloader 4.0.0 → 4.0.1
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/goldiloader/active_record_patches.rb +21 -18
- data/lib/goldiloader/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3da0240495233f97f9762b4c81249b24fc6b9fb39e46801243e865ae2ed4d50d
|
4
|
+
data.tar.gz: d5bc7704557c4a9cdaf4e8d8e31d7d066444a964faf31812ce34117f845ccbeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ab77e3c22b3e80dc903079dfe65245fceae13ab8b4fa1870705df1d1302eac82982523fad9cf7b9c2f4576022894ff16c8cd83b72d966ede5cd88ffb2b56d0
|
7
|
+
data.tar.gz: 402c5bfe96112e1a697af866205c3a16cb85966566adcac722deefc4ce4d487b4df10e335d1ce057cb2ddcf5ce4c8d490998c46b3e20feca4d98f334f2719534
|
@@ -68,23 +68,26 @@ module Goldiloader
|
|
68
68
|
ActiveRecord::Relation::Merger.prepend(::Goldiloader::MergerPatch)
|
69
69
|
|
70
70
|
module AssociationReflectionPatch
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
71
|
+
# Note we need to pass the association's target class as an argument since it won't be known
|
72
|
+
# outside the context of an association instance for polymorphic associations.
|
73
|
+
def eager_loadable?(target_klass)
|
74
|
+
@eager_loadable_cache ||= Hash.new do |cache, target_klass_key|
|
75
|
+
cache[target_klass_key] = if scope.nil?
|
76
|
+
# Associations without any scoping options are eager loadable
|
77
|
+
true
|
78
|
+
elsif scope.arity > 0
|
79
|
+
# The scope will be evaluated for every model instance so it can't
|
80
|
+
# be eager loaded
|
81
|
+
false
|
82
|
+
else
|
83
|
+
scope_info = Goldiloader::ScopeInfo.new(scope_for(target_klass_key.unscoped))
|
84
|
+
scope_info.auto_include? &&
|
85
|
+
!scope_info.limit? &&
|
86
|
+
!scope_info.offset? &&
|
87
|
+
(!has_one? || !scope_info.order?)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
@eager_loadable_cache[target_klass]
|
88
91
|
end
|
89
92
|
end
|
90
93
|
ActiveRecord::Reflection::AssociationReflection.include(::Goldiloader::AssociationReflectionPatch)
|
@@ -111,7 +114,7 @@ module Goldiloader
|
|
111
114
|
private
|
112
115
|
|
113
116
|
def eager_loadable?
|
114
|
-
reflection.eager_loadable? &&
|
117
|
+
klass && reflection.eager_loadable?(klass) &&
|
115
118
|
(::Goldiloader::Compatibility.destroyed_model_associations_eager_loadable? || !owner.destroyed?)
|
116
119
|
end
|
117
120
|
|
data/lib/goldiloader/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goldiloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Turkel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|