n1_loader 1.6.4 → 1.6.6

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: 7dbd6c49bba45473f2a822d02befa1ca0efdc155698648a17640c472ace4fccd
4
- data.tar.gz: db6c04d5cc63ddbcc8a3362fba985f478601e2b5ed0f5a298df992ecdc1e8f65
3
+ metadata.gz: f7d5587fbac0376006abf03b7beb385547b1c9206cdeea8461d9bf07b67e0df4
4
+ data.tar.gz: 6f94574d65b49c528a6af3e06d6d816ed78ef3cf3f6e14002249b816526cbb4a
5
5
  SHA512:
6
- metadata.gz: 397c84c6ee33547838c1155c58f7488dfef34028003d7da1c26a6f9a0f2be951bfe4ff4d7df761be6185ec58e36022ead691e434af708fd74ccb2cbae503e459
7
- data.tar.gz: 4a554a0f7aa8832b7aa81f32e8b0544baf060c0c8b59538f56e7d579b0e972e680a989ff41c7fe14c01665a7a2f8fb3883ca7ef98d60cc24005a68d3fe67bc6d
6
+ metadata.gz: 39d0370fee07be7e080adb22392633366da8cce0b74228c728b8647e9f7f859b4c995346bf0a8e9b477c355374b29f4f4690f089c6b6904822af3cfba88685af
7
+ data.tar.gz: 0245c5ba26df1d3f3508a22143ae5cb9d708c5460ef218ee2193b8cc537bf0ee6f6838357be50fe4d2d2d4c1db050e76a6176e98b3b7df4c64af4bf7b0e35e36
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.6.6] - 2023/07/30
2
+
3
+ - Fix naive check of required arguments. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for the issue!
4
+
5
+ ## [1.6.5] - 2023/07/30
6
+
7
+ - Fix nested preloading for ActiveRecord 7. Thanks [Igor Gonchar](https://github.com/gigorok) for the issue!
8
+
1
9
  ## [1.6.4] - 2023/07/30
2
10
 
3
11
  - Add support of `n1_optimized` ending with `?` (question mark). Thanks [Ilya Kamenko](https://github.com/Galathius) for the suggestion!
@@ -13,3 +13,7 @@ end
13
13
  N1Loader::LoaderCollection.define_method :run? do
14
14
  true
15
15
  end
16
+
17
+ N1Loader::LoaderCollection.define_method :future_classes do
18
+ []
19
+ end
@@ -62,22 +62,20 @@ module N1Loader
62
62
 
63
63
  attr_reader :elements, :args
64
64
 
65
- def check_missing_arguments! # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
65
+ def check_missing_arguments! # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
66
66
  return unless (arguments = self.class.arguments)
67
67
 
68
- min = arguments.count { |argument| !argument[:optional] }
69
- max = arguments.count
68
+ required_arguments = arguments.reject { |argument| argument[:optional] }
69
+ .map { |argument| argument[:name] }
70
70
 
71
- return if args.size >= min && args.size <= max
71
+ return if required_arguments.all? { |argument| args.key?(argument) }
72
72
 
73
- str =
74
- if min == max
75
- max.to_s
76
- else
77
- "#{min}..#{max}"
78
- end
73
+ missing_arguments = required_arguments.reject { |argument| args.key?(argument) }
74
+
75
+ list = missing_arguments.map { |argument| ":#{argument}" }.join(", ")
79
76
 
80
- raise MissingArgument, "Loader requires #{str} arguments but #{args.size} were given"
77
+ raise MissingArgument,
78
+ "Loader requires [#{list}] arguments but they are missing"
81
79
  end
82
80
 
83
81
  def check_arguments!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module N1Loader
4
- VERSION = "1.6.4"
4
+ VERSION = "1.6.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n1_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin