predictive_load 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 389078c86577ae35abeed91c62774ecf92924a19
|
4
|
+
data.tar.gz: 1ba0d8068de6029ecc853ae92b3068f827c6c067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 019bf857c563d681ac96c34bd97543c08046422ba8941d3441f5093297c13928e258b03194443749d4f6893394d7ab3b58eb1879aa03e6a751d5ab5f22330e5a
|
7
|
+
data.tar.gz: 8f6e11a32d2d372a9ce43e12f8f32c0d1d2eba2ac24425fc553905023814c3cb4db5d1f739a3746abe54cdcef5ca760b2cd7a1db3806d4c9cd67a68a42fd9874
|
@@ -39,10 +39,10 @@ module PredictiveLoad::ActiveRecordCollectionObservation
|
|
39
39
|
def unscoped
|
40
40
|
if block_given?
|
41
41
|
begin
|
42
|
-
|
42
|
+
predictive_load_disabled << self
|
43
43
|
super
|
44
44
|
ensure
|
45
|
-
|
45
|
+
predictive_load_disabled.pop
|
46
46
|
end
|
47
47
|
else
|
48
48
|
super
|
@@ -50,12 +50,8 @@ module PredictiveLoad::ActiveRecordCollectionObservation
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def predictive_load_disabled=(value)
|
54
|
-
Thread.current[:predictive_load_disabled] = value
|
55
|
-
end
|
56
|
-
|
57
53
|
def predictive_load_disabled
|
58
|
-
Thread.current[:predictive_load_disabled]
|
54
|
+
Thread.current[:predictive_load_disabled] ||= []
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
@@ -40,11 +40,18 @@ module PredictiveLoad
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def supports_preload?(association)
|
43
|
-
return false if ActiveRecord::Base.predictive_load_disabled
|
43
|
+
return false if ActiveRecord::Base.predictive_load_disabled.include?(association.klass)
|
44
44
|
return false if association.reflection.options[:predictive_load] == false
|
45
45
|
return false if association.reflection.options[:conditions].respond_to?(:to_proc) # rails 3 conditions proc (we do not know if it uses instance methods)
|
46
|
-
if ActiveRecord::VERSION::MAJOR > 3
|
47
|
-
|
46
|
+
if ActiveRecord::VERSION::MAJOR > 3 && scope = association.reflection.scope
|
47
|
+
if scope.is_a?(Proc)
|
48
|
+
# rails 4+ conditions block, if it uses a passed in object, we assume it is not preloadable
|
49
|
+
return false if scope.arity.to_i > 0
|
50
|
+
elsif where = scope.options[:where]
|
51
|
+
# ActiveRecord::Associations::Builder::DeprecatedOptionsProc from rails 4.0 and deprecated finders
|
52
|
+
# when conditions was a proc the where will be a proc too -> check arity
|
53
|
+
return false if where.is_a?(Proc) && where.arity > 0
|
54
|
+
end
|
48
55
|
end
|
49
56
|
true
|
50
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: predictive_load
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Chapweske
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|