class StashedInstanceMethod

@private

Public Class Methods

new(klass, method) click to toggle source
# File lib/rspec/mocks/stashed_instance_method.rb, line 3
def initialize(klass, method)
  @klass = klass
  @method = method

  @method_is_stashed = false
end

Public Instance Methods

restore() click to toggle source

@private

# File lib/rspec/mocks/stashed_instance_method.rb, line 53
def restore
  return unless @method_is_stashed

  @klass.__send__(:alias_method, @method, stashed_method_name)
  @klass.__send__(:remove_method, stashed_method_name)
  @method_is_stashed = false
end
stash() click to toggle source

@private

# File lib/rspec/mocks/stashed_instance_method.rb, line 11
def stash
  return if !method_defined_directly_on_klass? || @method_is_stashed

  @klass.__send__(:alias_method, stashed_method_name, @method)
  @method_is_stashed = true
end