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?)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue