class Delfos::Patching::Unstubber

Public Class Methods

unstub!(klass, method_name, class_method) click to toggle source
# File lib/delfos/patching/unstubber.rb, line 23
def self.unstub!(klass, method_name, class_method)
  module_definition(klass, method_name, class_method) do |m|
    begin
      remove_method :"#{method_name}"
    rescue NameError => e
      raise unless e.message["method `#{method_name}' not defined in"]
    end
  end
end
unstub_all!() click to toggle source
# File lib/delfos/patching/unstubber.rb, line 7
def self.unstub_all!
  MUTEX.synchronize do
    Thread.current[:__delfos_disable_patching] = true
  end

  MethodCache.each_method do |klass_name, method, class_method|
    klass = eval(klass_name)

    unstub!(klass, method.name, class_method)
  end

  MUTEX.synchronize do
    Thread.current[:__delfos_disable_patching] = false
  end
end