n1_loader 1.6.0 → 1.6.1

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: 3d914dd09225515a579945ab616916bf1ad446101c5051c4cf1b72c46d38c107
4
- data.tar.gz: a304c32e35294c5646fafe5c65a5de6c637e80e080d80ac16f957d77a3ebe4c6
3
+ metadata.gz: 241044074fba6a2a10e22cae353f7e503cfbe93e403ab9016cb5651da7b3bae1
4
+ data.tar.gz: 594e2ebd313744710547aedadb6b5159a6d5fa935807c59232091c71c45b0a0b
5
5
  SHA512:
6
- metadata.gz: 738d8ca021bca48a41486689c74506af32dc2bca8a542398272edaa72aa57dd49247249d04afe8d9b834cc28cd9b725f0a9b1d8d7f5dd80176cfd3c9ca711f08
7
- data.tar.gz: c73ddc81593e0cbd0450457143726b9d57fbce0a27c09ede70ea3f269816b7ae7374e5dc1c06dda4e8b0ee8c21a0c96248ed4afb9e3d7f26ec5b5ac46e038d16
6
+ metadata.gz: 68d3565e4624a0488e0f53190bf5d5817d784d2deccb2006c816b207ca71d25df7447487e75c09645ddd82f6c76c3264cdbbeabef10ab687b5980d997b73eedd
7
+ data.tar.gz: 9ea2e502dec4367f717bb848697a15bb7c28b26d182218710185e39cb36196f00d18dd36f223f2443925a30f7a14407375ae95072575ce03a66bc79ef113c982
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.6.1] - 2022/10/29
2
+
3
+ - Fix ArLazyPreload context setup when using isolated loaders for objects without the context.
4
+
1
5
  ## [1.6.0] - 2022/10/24
2
6
 
3
7
  - Add support of ArLazyPreload context for isolated loaders.
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Raised when a single object without ArLazyPreload context was passed to an isolated loader.
4
- N1Loader::Loader::MissingArLazyPreloadContext = Class.new(StandardError)
3
+ # Raised when a single object without ArLazyPreload context support was passed to an isolated loader.
4
+ N1Loader::Loader::UnsupportedArLazyPreload = Class.new(StandardError)
5
5
 
6
6
  # Defines a singleton method method that allows isolated loaders
7
7
  # to use ArLazyPreload context without passing sibling records.
8
8
  N1Loader::Loader.define_singleton_method(:for) do |element, **args|
9
- # It is required to have an ArLazyPreload context defined
10
- if !element.respond_to?(:lazy_preload_context) || element.lazy_preload_context.nil?
11
- raise N1Loader::Loader::MissingArLazyPreloadContext
9
+ # It is required to have an ArLazyPreload context supported
10
+ raise N1Loader::Loader::UnsupportedArLazyPreload unless element.respond_to?(:lazy_preload_context)
11
+
12
+ if element.lazy_preload_context.nil?
13
+ ArLazyPreload::Context.register(
14
+ records: [element],
15
+ association_tree: [],
16
+ auto_preload: true
17
+ )
12
18
  end
13
19
 
14
20
  # Fetch or initialize loader from ArLazyPreload context
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module N1Loader
4
- VERSION = "1.6.0"
4
+ VERSION = "1.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n1_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-24 00:00:00.000000000 Z
11
+ date: 2022-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord