Skip to content

Instantly share code, notes, and snippets.

@banister
Created August 22, 2012 02:29
Show Gist options
  • Save banister/3421623 to your computer and use it in GitHub Desktop.
Save banister/3421623 to your computer and use it in GitHub Desktop.
[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