Retire check for method presence

bind_call introduced in 2.7
This commit is contained in:
Nikita Shilnikov 2022-10-30 20:55:29 +03:00
parent 922470898f
commit fc9d89b271
No known key found for this signature in database
GPG Key ID: E569D1D64C40E241
1 changed files with 7 additions and 20 deletions

View File

@ -15,27 +15,14 @@ module Dry
KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
private_constant(:KERNEL_RESPOND_TO)
if ::UnboundMethod.method_defined?(:bind_call)
# @api private
def initialize(predicates = Logic::Predicates)
@predicates = predicates
end
# @api private
def initialize(predicates = Logic::Predicates)
@predicates = predicates
end
# @api private
def key?(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
# @api private
def key?(name)
KERNEL_RESPOND_TO.bind_call(@predicates, name)
end
# @api private