lib/dry/schema/extensions/hints/message_compiler_methods.rb in dry-schema-1.8.0 vs lib/dry/schema/extensions/hints/message_compiler_methods.rb in dry-schema-1.9.0
- old
+ new
@@ -33,16 +33,18 @@
def filter(messages, opts)
Array(messages).flatten.map { |msg| msg unless exclude?(msg, opts) }.compact.uniq
end
# @api private
+ # rubocop: disable Metrics/AbcSize
+ # rubocop: disable Metrics/PerceivedComplexity
+ # rubocop: disable Metrics/CyclomaticComplexity
def exclude?(messages, opts)
Array(messages).all? do |msg|
- hints = opts
- .hints
- .reject { |hint| msg == hint }
- .reject { |hint| hint.predicate == :filled? }
+ hints = opts.hints.reject { |h|
+ msg.eql?(h) || h.predicate.eql?(:filled?)
+ }
key_failure = opts.key_failure?(msg.path)
predicate = msg.predicate
(HINT_TYPE_EXCLUSION.include?(predicate) && !key_failure) ||
@@ -50,9 +52,12 @@
(!key_failure && HINT_TYPE_EXCLUSION.include?(predicate) &&
!hints.empty? && hints.any? { |hint| hint.path == msg.path }) ||
HINT_OTHER_EXCLUSION.include?(predicate)
end
end
+ # rubocop: enable Metrics/CyclomaticComplexity
+ # rubocop: enable Metrics/PerceivedComplexity
+ # rubocop: enable Metrics/AbcSize
# @api private
def message_type(options)
options[:message_type].equal?(:hint) ? Hint : Message
end