lib/dry/schema/path.rb in dry-schema-1.5.5 vs lib/dry/schema/path.rb in dry-schema-1.5.6

- old
+ new

@@ -89,31 +89,28 @@ def index(key) keys.index(key) end def without_index - self.class.new([*to_a[0..-2]]) + self.class.new(to_a[0..-2]) end # @api private - # - # rubocop:disable Metrics/PerceivedComplexity def include?(other) - return false unless same_root?(other) - return last.equal?(other.last) if index? && other.index? - return without_index.include?(other) if index? - - if !index? && other.index? - path = key_matches(other, :select) - - return false unless path.size > 1 - - self.class.new(path).include?(other) + if !same_root?(other) + false + elsif index? + if other.index? + last.equal?(other.last) + else + without_index.include?(other) + end + elsif other.index? && key_matches(other, :select).size < 2 + false + else + self >= other && !other.key_matches(self).include?(nil) end - - self >= other && !other.key_matches(self).include?(nil) end - # rubocop:enable Metrics/PerceivedComplexity # @api private def <=>(other) raise ArgumentError, "Can't compare paths from different branches" unless same_root?(other)