Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created January 7, 2011 12:05
Show Gist options
  • Save slawosz/769398 to your computer and use it in GitHub Desktop.
Save slawosz/769398 to your computer and use it in GitHub Desktop.
use module hierarchy!
# people write such a code
class Person
def say(word)
puts word
end
end
class Person
alias_method :old_say, :say
def say(word)
old_say(word.uppercase)
end
end
#instead of this!
module Speaker
def say(word)
puts word
end
end
class Person
include Speaker
end
module LoudSpeaker
def say(word)
super(word.uppercase)
end
end
class Person
include LoudSpeaker
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment