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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/n1_loader/ar_lazy_preload/loader.rb +11 -5
- data/lib/n1_loader/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: 241044074fba6a2a10e22cae353f7e503cfbe93e403ab9016cb5651da7b3bae1
|
4
|
+
data.tar.gz: 594e2ebd313744710547aedadb6b5159a6d5fa935807c59232091c71c45b0a0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68d3565e4624a0488e0f53190bf5d5817d784d2deccb2006c816b207ca71d25df7447487e75c09645ddd82f6c76c3264cdbbeabef10ab687b5980d997b73eedd
|
7
|
+
data.tar.gz: 9ea2e502dec4367f717bb848697a15bb7c28b26d182218710185e39cb36196f00d18dd36f223f2443925a30f7a14407375ae95072575ce03a66bc79ef113c982
|
data/CHANGELOG.md
CHANGED
@@ -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::
|
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
|
10
|
-
|
11
|
-
|
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
|
data/lib/n1_loader/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|