class Spy::Strategy::Intercept

Public Class Methods

new(spy) click to toggle source
# File lib/spy/strategy/intercept.rb, line 6
def initialize(spy)
  @spy = spy
  @target =
    case spy.original
    when Method
      spy.spied.singleton_class
    when UnboundMethod
      spy.spied
    when FakeMethod
      spy.spied.singleton_class
    end
end

Public Instance Methods

apply() click to toggle source
# File lib/spy/strategy/intercept.rb, line 19
def apply
  ReplaceMethod.call(@target, @spy, mode: :stub)
end
undo() click to toggle source
# File lib/spy/strategy/intercept.rb, line 23
def undo
  ReplaceMethod.call(@target, @spy, remove_existing: true)
end