Module: Kernel
- Defined in:
- lib/cordon.rb
Overview
Patch ALL the monkeys!
Instance Method Summary collapse
-
#__cordon__wrap_method__(method) ⇒ Object
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).
Instance Method Details
#__cordon__wrap_method__(method) ⇒ Object
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)
15 16 17 18 19 20 21 22 23 24 |
# 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 |