ar_lazy_preload 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ar_lazy_preload/active_record/base.rb +11 -4
- data/lib/ar_lazy_preload/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: 5c0652f697df796459ee3750a5a5e54d94bbc1539f0a330f06c24a507f14004e
|
4
|
+
data.tar.gz: ca559bf8f481486ce7fadf75c0e0fa2e2ec1d25babdb1dee590fecbc117c5d3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a2bc64e535ff7ba87fa57b568414c87b24ce358bd6587128bfc7d153d055a9187b8162964639d72adf53b22f92fe22970c5a906ce891054161cea5a9e754f2
|
7
|
+
data.tar.gz: aef7c0d8d88f8fea6de1f81abc89baa9aa2fa5fed2b74a9d3eb16e21cd057efacc735c8d46406c54cd4bf3c2e3ac3fed025b95e2a3e9c7188554eff2a6afe442
|
@@ -6,15 +6,18 @@ module ArLazyPreload
|
|
6
6
|
def self.included(base)
|
7
7
|
base.class.delegate :lazy_preload, to: :all
|
8
8
|
base.class.delegate :preload_associations_lazily, to: :all
|
9
|
+
|
9
10
|
base.after_create { try_setup_auto_preload_context }
|
11
|
+
|
12
|
+
base.extend(ClassMethods)
|
10
13
|
end
|
11
14
|
|
12
15
|
attr_accessor :lazy_preload_context
|
13
16
|
|
14
17
|
delegate :try_preload_lazily, to: :lazy_preload_context, allow_nil: true
|
15
18
|
|
16
|
-
def reload
|
17
|
-
super.tap { try_setup_auto_preload_context }
|
19
|
+
def reload(options = nil)
|
20
|
+
super(options).tap { try_setup_auto_preload_context }
|
18
21
|
end
|
19
22
|
|
20
23
|
def skip_preload
|
@@ -23,10 +26,14 @@ module ArLazyPreload
|
|
23
26
|
self
|
24
27
|
end
|
25
28
|
|
26
|
-
private
|
27
|
-
|
28
29
|
def try_setup_auto_preload_context
|
29
30
|
ArLazyPreload::Context.register(records: [self]) if ArLazyPreload.config.auto_preload?
|
30
31
|
end
|
32
|
+
|
33
|
+
module ClassMethods
|
34
|
+
def find_by(*args)
|
35
|
+
super(*args).tap { |object| object&.try_setup_auto_preload_context }
|
36
|
+
end
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_lazy_preload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|