goldiloader 4.1.1 → 4.1.2

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: 452d46a8d8dc72a51e686d522826ad8f80ad3e686ef03d61f34c8044458f1d3f
4
- data.tar.gz: f4c428261a9d7d69858e065da735795b7be00bae3d6c4910b5e9d31064558e51
3
+ metadata.gz: 14cd0ebc332f63f4f019029af0c75254207ad6b3957d3204b458200ffe89aa61
4
+ data.tar.gz: 151fe68d70ebc800bd471204106d49e7208678b6f0d5e1495a08302859f8574d
5
5
  SHA512:
6
- metadata.gz: ebf67521e4fed82d0d90b5f1597b296e0de04f53ab35b975c5e48383fa6392b0a4d0ed91225e16e471bfa87840144d68d590711e92353cd6138a637b94b5aa30
7
- data.tar.gz: ee9fac3561f9e8c875f4bcbaca2fa9cbf7be9d3450f440e77eddcc3816da80fd4a38d534128e78fa154ce6ebaa83f99e502b838b7be106aa8bbe7db75466022e
6
+ metadata.gz: 4b387491503a50e6108c0fb3df8419eaea1032a302908afbaa0302582e37819250eecf569fb53c7eb29f4d204fe2d799b4fd0e5f71f9afc026b104370e5132b6
7
+ data.tar.gz: 62554443b9814f9487f63a39e2cd6c0da8bd85fc0985fc87f078e21b812f91d453676c72db9794d8d40fb5d04edd3e7220cad9aaf2c7bb94c374604b6b8de815
@@ -15,7 +15,7 @@ module Goldiloader
15
15
  private
16
16
 
17
17
  def eager_load(models, association_name)
18
- if Goldiloader::Compatibility.pre_rails_6_2?
18
+ if Goldiloader::Compatibility.pre_rails_7?
19
19
  ::ActiveRecord::Associations::Preloader.new.preload(models, [association_name])
20
20
  else
21
21
  ::ActiveRecord::Associations::Preloader.new(records: models, associations: [association_name]).call
@@ -37,7 +37,13 @@ module Goldiloader
37
37
  end
38
38
 
39
39
  def register_models(models)
40
- Array.wrap(models).each do |model|
40
+ # Don't use Array() or Array.wrap() because they will check respond_to?(:to_ary)
41
+ # which for ActiveStorage::Attachment will delegate to the blob association which
42
+ # triggers an infinite eager loading loop on the association
43
+ models = [models] unless models.is_a?(Array)
44
+ models.each do |model|
45
+ next if model.nil?
46
+
41
47
  model.auto_include_context = self
42
48
  self.models << model
43
49
  end
@@ -3,11 +3,22 @@
3
3
  module Goldiloader
4
4
  module Compatibility
5
5
  ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING).release
6
- PRE_RAILS_6_2 = ACTIVE_RECORD_VERSION < ::Gem::Version.new('6.2.0')
7
6
  RAILS_5_2_0 = ACTIVE_RECORD_VERSION == ::Gem::Version.new('5.2.0')
8
7
 
9
- def self.pre_rails_6_2?
10
- PRE_RAILS_6_2
8
+ def self.pre_rails_7?
9
+ ::ActiveRecord::VERSION::MAJOR < 7
10
+ end
11
+
12
+ def self.rails_5_2?
13
+ ::ActiveRecord::VERSION::MAJOR == 5 && ::ActiveRecord::VERSION::MINOR == 2
14
+ end
15
+
16
+ def self.rails_6_1?
17
+ ::ActiveRecord::VERSION::MAJOR == 6 && ::ActiveRecord::VERSION::MINOR == 1
18
+ end
19
+
20
+ def self.rails_6_1_or_greater?
21
+ ::ActiveRecord::VERSION::MAJOR > 6 || rails_6_1?
11
22
  end
12
23
 
13
24
  # See https://github.com/rails/rails/pull/32375
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Goldiloader
4
- VERSION = '4.1.1'
4
+ VERSION = '4.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goldiloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -50,6 +50,26 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '7.1'
53
+ - !ruby/object:Gem::Dependency
54
+ name: activestorage
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '5.2'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '7.1'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '5.2'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '7.1'
53
73
  - !ruby/object:Gem::Dependency
54
74
  name: appraisal
55
75
  requirement: !ruby/object:Gem::Requirement