Created
August 22, 2012 02:29
-
-
Save banister/3421623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[27] (pry) main: 0> class Pig | |
[27] (pry) main: 0* def self.fowlie | |
[27] (pry) main: 0* puts "fowlie" | |
[27] (pry) main: 0* end | |
[27] (pry) main: 0* cm = "fowlie" | |
[27] (pry) main: 0* class << self; self; end.class_eval do | |
[27] (pry) main: 0* alias_method "original_#{cm}", cm | |
[27] (pry) main: 0* def fowlie | |
[27] (pry) main: 0* original_fowlie | |
[27] (pry) main: 0* puts "decorated fowlie" | |
[27] (pry) main: 0* end | |
[27] (pry) main: 0* end | |
[27] (pry) main: 0* end | |
=> nil | |
[28] (pry) main: 0> Pig.fowlie | |
fowlie | |
decorated fowlie | |
=> nil | |
[29] (pry) main: 0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment