ar_lazy_preload 1.1.0 → 1.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c318927cb52d775d3a85e91fb24b7102e9fcb8004ced72fc1482ec0c7c4d1269
4
- data.tar.gz: 8ceb003e63266df93da708925b261fab06334758366ce68b361609c2dbd07682
3
+ metadata.gz: 5c0652f697df796459ee3750a5a5e54d94bbc1539f0a330f06c24a507f14004e
4
+ data.tar.gz: ca559bf8f481486ce7fadf75c0e0fa2e2ec1d25babdb1dee590fecbc117c5d3c
5
5
  SHA512:
6
- metadata.gz: 9d52b4b8293a9e0c2eaa47bf21b603d1066d7b18b738e724a3b16b20188a56326bd4a52d9397481ef81fcbec368e1929ff4679fe7cfb47ba3d704421eda2ad83
7
- data.tar.gz: 716b102784e7c22119320d7cc5ae513dcb8f2097eb5dba31e50fbbe64940f96324eff7ed2410eea6171a899880b4fc81683d2b43233607ea12740693b8358b69
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArLazyPreload
4
- VERSION = "1.1.0"
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.0
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-30 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