hacks/override_method |
class Module < Object |
Public Methods |
A clean way to override methods without resorting to alias_method. The original method can be called with super().
This works by giving the current class two anonymous base classes: one containing the original method, and one containing the new method. Thus, the original method must NOT make a call to super().
class Foo def foo puts "foo!" endoverride_method :foo do def foo puts "foo 2!" super() end end
override_method :foo do def foo puts "foo 3!" super() end end end
Foo.new.foo #=> foo 3! #=> foo 2! #=> foo 1!
symbols | a list of symbols to override |
---|---|
block | a block which defines the new methods. |
Mixins |
new_methods |
---|