-
-
Save ukstudio/1721687 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
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
class Foo | |
def self.show | |
'foo' | |
end | |
end | |
module Bar | |
def self.included(base) | |
base.extend ClassMethods | |
base.instance_eval do | |
alias :show_without_bar :show | |
alias :show :show_with_bar | |
end | |
end | |
module ClassMethods | |
def show_with_bar | |
"#{show_without_bar} bar" | |
end | |
end | |
end | |
Foo.send :include, Bar | |
puts Foo.show #=> foo bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment