ar_lazy_preload 1.1.1 → 1.1.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
  SHA256:
3
- metadata.gz: 5ef8cbc0a242dd2fa52cef2fd1d717038958ba790dff71ac98342607818c5f2b
4
- data.tar.gz: 5577042748209210f9a3572c3ddca024b33b5057fe8802b3aaa2868fb5c30b89
3
+ metadata.gz: 5c0652f697df796459ee3750a5a5e54d94bbc1539f0a330f06c24a507f14004e
4
+ data.tar.gz: ca559bf8f481486ce7fadf75c0e0fa2e2ec1d25babdb1dee590fecbc117c5d3c
5
5
  SHA512:
6
- metadata.gz: 2a4370f4a24e804dd9a12475df32153c1e1d507a311252a080565d1576a37c0b355f5e74477ae67bdae813ae5a8cda46956b914dfb8654710a2e83a8c84b2f13
7
- data.tar.gz: 79d3318b88f63b0d5ddfb1530055a1846436fdb82c83ed4d44e006563381150dbe5755ed66134cbdf76c6c5f771088743774ce8528923b8b4a97bf8669134139
6
+ metadata.gz: c3a2bc64e535ff7ba87fa57b568414c87b24ce358bd6587128bfc7d153d055a9187b8162964639d72adf53b22f92fe22970c5a906ce891054161cea5a9e754f2
7
+ data.tar.gz: aef7c0d8d88f8fea6de1f81abc89baa9aa2fa5fed2b74a9d3eb16e21cd057efacc735c8d46406c54cd4bf3c2e3ac3fed025b95e2a3e9c7188554eff2a6afe442
@@ -6,7 +6,10 @@ 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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArLazyPreload
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  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.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-12-01 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails