ar_lazy_preload 0.4.0 → 0.5.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 122262e10bed3d8a2793e62f24ee39e7a01453933c68d8faffce8945b794a522
|
4
|
+
data.tar.gz: e50652dd855cbbbe39b292b20e07fca7f43ba660fd2f28f0c41de1fa0595c281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97a5044a80f021ea4f4c0bd0b27b0881858371bb60051014f885c791570346bafae8c2e4110f5f492817cbe38d44c551a4045d886a67e1ede30a5af5079afdac
|
7
|
+
data.tar.gz: '0458891f44c12464f6ce33295c6ef4e20bf55df63dc81a46ad840401cb47f1a782c466ee87f4c44c965b5090bc1c02ed2bead8a90f9b5031f9665803ade8e0a6'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ArLazyPreload
|
4
4
|
# ActiveRecord::CollectionAssociation patch with a hook for lazy preloading
|
5
5
|
module CollectionAssociation
|
6
|
-
# rubocop:disable Metrics/AbcSize
|
6
|
+
# rubocop:disable Metrics/AbcSize
|
7
7
|
def ids_reader
|
8
8
|
return super if owner.lazy_preload_context.blank?
|
9
9
|
|
@@ -16,6 +16,6 @@ module ArLazyPreload
|
|
16
16
|
@association_ids ||= reader.map(&primary_key)
|
17
17
|
end
|
18
18
|
end
|
19
|
-
# rubocop:enable Metrics/AbcSize
|
19
|
+
# rubocop:enable Metrics/AbcSize
|
20
20
|
end
|
21
21
|
end
|
@@ -8,8 +8,8 @@ module ArLazyPreload
|
|
8
8
|
# the associated records based on the parent association tree.
|
9
9
|
class AssociatedContextBuilder
|
10
10
|
# Initiates lazy preload context the records loaded lazily
|
11
|
-
def self.prepare(
|
12
|
-
new(
|
11
|
+
def self.prepare(**args)
|
12
|
+
new(**args).perform
|
13
13
|
end
|
14
14
|
|
15
15
|
attr_reader :parent_context, :association_name
|
@@ -23,7 +23,8 @@ module ArLazyPreload
|
|
23
23
|
|
24
24
|
# Takes all the associated records for the records, attached to the :parent_context and creates
|
25
25
|
# a preloading context for them
|
26
|
-
|
26
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
27
|
+
def perform
|
27
28
|
associated_records = parent_context.records.flat_map do |record|
|
28
29
|
next if record.nil?
|
29
30
|
|
@@ -38,6 +39,7 @@ module ArLazyPreload
|
|
38
39
|
auto_preload: parent_context.auto_preload?
|
39
40
|
)
|
40
41
|
end
|
42
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
41
43
|
|
42
44
|
private
|
43
45
|
|
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: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.81.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.81.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: db-query-matchers
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
- !ruby/object:Gem::Version
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
199
|
+
rubygems_version: 3.1.2
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: lazy_preload implementation for ActiveRecord models
|