Retire check for method presence
bind_call introduced in 2.7
This commit is contained in:
parent
922470898f
commit
fc9d89b271
|
@ -15,27 +15,14 @@ module Dry
|
||||||
KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
|
KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
|
||||||
private_constant(:KERNEL_RESPOND_TO)
|
private_constant(:KERNEL_RESPOND_TO)
|
||||||
|
|
||||||
if ::UnboundMethod.method_defined?(:bind_call)
|
# @api private
|
||||||
# @api private
|
def initialize(predicates = Logic::Predicates)
|
||||||
def initialize(predicates = Logic::Predicates)
|
@predicates = predicates
|
||||||
@predicates = predicates
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
def key?(name)
|
def key?(name)
|
||||||
KERNEL_RESPOND_TO.bind_call(@predicates, name)
|
KERNEL_RESPOND_TO.bind_call(@predicates, name)
|
||||||
end
|
|
||||||
else
|
|
||||||
# @api private
|
|
||||||
def initialize(predicates = Logic::Predicates)
|
|
||||||
@predicates = predicates
|
|
||||||
@has_predicate = KERNEL_RESPOND_TO.bind(@predicates)
|
|
||||||
end
|
|
||||||
|
|
||||||
# @api private
|
|
||||||
def key?(name)
|
|
||||||
has_predicate.(name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
|
|
Loading…
Reference in New Issue