Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Forked from mashiro/test.rb
Created February 2, 2012 05:28
Show Gist options
  • Save ukstudio/1721687 to your computer and use it in GitHub Desktop.
Save ukstudio/1721687 to your computer and use it in GitHub Desktop.
#!/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