lib/dry/behaviour/black_tie.rb in dry-behaviour-0.11.1 vs lib/dry/behaviour/black_tie.rb in dry-behaviour-0.11.2
- old
+ new
@@ -122,15 +122,15 @@
acc << m
end
end.each do |m|
target = [target] unless target.is_a?(Array)
target.each do |tgt|
+ params = mod.method(m).parameters.reject { |_, v| v.to_s[/\A♿_/] }
+ proto = BlackTie.protocols[protocol]
ok =
mds.map(&:first).include?(m) ||
- [
- BlackTie.protocols[protocol][m],
- mod.method(m).parameters.reject { |_, v| v.to_s[/\A♿_/] }
- ].map(&:first).reduce(:==)
+ ((proto[m] == {} || proto[:__implicit_inheritance__]) && [[:req], [:rest]].include?(params.map(&:first))) ||
+ [proto[m], params].map { |args| args.map(&:first) }.reduce(:==)
# TODO[1.0] raise NotImplemented(:arity)
BlackTie.Logger.warn(
WRONG_PARAMETER_DECLARATION % [Dry::BlackTie.proto_caller, protocol.inspect, m, target, BlackTie.protocols[protocol][m].map(&:first)]
) unless ok