module Kernel

Patch ALL the monkeys!

Public Instance Methods

__cordon__wrap_method__(method) click to toggle source

This bit of metaprogramming replaces a blacklisted method with a hook that calls back into the #__cordon__call_method__ defined in Cordon::Sanitaire (and, therefore, mixed in to Object)

# File lib/cordon.rb, line 15
def __cordon__wrap_method__(method)
  # Take advantage of the fact that the block passed to define_method is a closure,
  # so we can find the blacklisted method quickly.
  # Use a name unlikely to collide in the object's own binding.
  __cordon__receiver__ = self
  define_method(method) do |*args, &b|
    subject = __cordon__receiver__
    __cordon__call_method__(subject, method, *args, &b)
  end
end