n1_loader 1.6.5 → 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: 3b7ac1fa217041b1142d51fe619c44f6f1cbc16e2d7c2606c5cb4f023f7a19ac
4
- data.tar.gz: a62833353c2699c369d3581b239f0b8f67b87b6435cc4cba4995661bc83c9174
3
+ metadata.gz: f7d5587fbac0376006abf03b7beb385547b1c9206cdeea8461d9bf07b67e0df4
4
+ data.tar.gz: 6f94574d65b49c528a6af3e06d6d816ed78ef3cf3f6e14002249b816526cbb4a
5
5
  SHA512:
6
- metadata.gz: c4f17f1bb93729de61ecbd636837323070c65a48f54b4fb6917cf1b24bc5a2b416826498eca11722779aafca09c9f4df150687aed331b6dae2fa9172c024aab4
7
- data.tar.gz: 102ed2741ad8af210182576df8ceba4293d829b0c4489d6f15a5823dcfe0de976a4ecb604c57fe6383cdf243cc2e4fc510a3f1d8ee1d1e4cfc0c7b5ec0941e65
6
+ metadata.gz: 39d0370fee07be7e080adb22392633366da8cce0b74228c728b8647e9f7f859b4c995346bf0a8e9b477c355374b29f4f4690f089c6b6904822af3cfba88685af
7
+ data.tar.gz: 0245c5ba26df1d3f3508a22143ae5cb9d708c5460ef218ee2193b8cc537bf0ee6f6838357be50fe4d2d2d4c1db050e76a6176e98b3b7df4c64af4bf7b0e35e36
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
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
+
1
5
  ## [1.6.5] - 2023/07/30
2
6
 
3
7
  - Fix nested preloading for ActiveRecord 7. Thanks [Igor Gonchar](https://github.com/gigorok) for the issue!
@@ -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.5"
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.5
4
+ version: 1.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin