Skip to content

Commit

Permalink
Get rid of YARD error
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 19, 2021
1 parent 115c56c commit 7de060b
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions lib/rspec/mocks/verifying_double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,36 @@ def respond_to?(message, include_private=false)
# Get rid of calling overridden `method_missing`
missing_method = ::BasicObject.instance_method(:method_missing)

unless missing_method.respond_to?(:bind_call) # < Ruby 2.7
def missing_method.bind_call(receiver, *args, &block)
bind(receiver).call(*args, &block)
class << missing_method
unless method_defined?(:bind_call) # < Ruby 2.7
# @private
def bind_call(receiver, *args, &block)
bind(receiver).call(*args, &block)
end
end
end

# Tell whether the method call which caused `method_missing`
# was called in the private or public form, by using
# `NoMethodError#private_call?`.
def missing_method.private_call?(object, message)
bind_call(object, message)
rescue NoMethodError => e
e.private_call?
rescue NameError # without receiver, arguments and parentheses
true
else # should not happen
false
# Tell whether the method call which caused `method_missing`
# was called in the private or public form, by using
# `NoMethodError#private_call?`.
# @private
def private_call?(object, message)
bind_call(object, message)
rescue NoMethodError => e
e.private_call?
rescue NameError # without receiver, arguments and parentheses
true
else # should not happen
false
end
end
else
missing_method = (defined?(::BasicObject) ? ::BasicObject : ::Object).new

def missing_method.private_call?(object, message)
object.instance_variable_get(:@__sending_message) == message
class << missing_method
# @private
def private_call?(object, message)
object.instance_variable_get(:@__sending_message) == message
end
end

# Redefining `__send__` causes ruby to issue a warning.
Expand Down

0 comments on commit 7de060b

Please sign in to comment.