active_record_custom_preloader 1.0.0 → 2.0.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: 7c5402d3636a7fc7337118a453032e0f0a38cf241e31f603842e109ae1e10b80
|
4
|
+
data.tar.gz: 8cc9d34c0075cb1194c3d36173886bb2be6297368216ddf49e4f9f1122505cfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f463d113f55c2611f38eae30b9174ece10f06f9d0ead2b21f345234e2a93af628ebf153fc44e7c73667d9dc9eea295f7d016bf4522a179509a83ea730315b4a
|
7
|
+
data.tar.gz: e6ca5f43a6327cd9181a0d3503406634a394f88a7d890afddb99ef3baec266eef0b53b5222269161d149991c1cfa0aa37550b3d663bf3d61224ccd73d31b3545
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# ActiveRecordCustomPreloader
|
2
2
|
|
3
|
-
|
3
|
+
Custom preloader for ActiveRecord model.
|
4
|
+
|
5
|
+
Gem version `2.X.X` and `master` branch compatible with Rails `6.X.X` and upper.
|
6
|
+
For Rails `5.X.X` see branch `rails-5` and gem version `1.X.X`.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
26
|
spec.add_dependency 'activesupport'
|
27
|
-
spec.add_dependency 'activerecord', '
|
27
|
+
spec.add_dependency 'activerecord', '>= 6.0.0'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
30
30
|
spec.add_development_dependency 'rake', '~> 10.0'
|
@@ -5,23 +5,23 @@ module ActiveRecordCustomPreloader
|
|
5
5
|
class AssociationsPreloader < ::ActiveRecord::Associations::Preloader
|
6
6
|
private
|
7
7
|
|
8
|
-
def preloaders_on(association, records, scope)
|
8
|
+
def preloaders_on(association, records, scope, polymorphic_parent = false)
|
9
9
|
if association.is_a?(PreloadWithOptions)
|
10
|
-
preloaders_for_one(association, records, scope)
|
10
|
+
preloaders_for_one(association, records, scope, polymorphic_parent)
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
14
14
|
klass = records.first.class
|
15
15
|
if klass.respond_to?(:has_custom_loader?) && klass.has_custom_loader?(association)
|
16
16
|
association = PreloadWithOptions.new(association)
|
17
|
-
preloaders_for_one(association, records, scope)
|
17
|
+
preloaders_for_one(association, records, scope, polymorphic_parent)
|
18
18
|
return
|
19
19
|
end
|
20
20
|
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
|
-
def preloaders_for_one(association, records, scope)
|
24
|
+
def preloaders_for_one(association, records, scope, polymorphic_parent)
|
25
25
|
if records.size > 0 && association.is_a?(PreloadWithOptions)
|
26
26
|
association.loader_for(records.first.class).preload(records)
|
27
27
|
return
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_custom_preloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Talakevich
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.7.10
|
144
|
+
rubygems_version: 3.1.2
|
146
145
|
signing_key:
|
147
146
|
specification_version: 4
|
148
147
|
summary: Custom preloader for ActiveRecord.
|