Created
December 4, 2011 17:59
-
-
Save metaskills/1430833 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-local-exec | |
require 'rubygems' | |
require 'active_support' | |
require 'active_support/core_ext' | |
class Foo | |
def self.bar | |
'bar' | |
end | |
def batz | |
'batz' | |
end | |
end | |
module MetaSkills | |
extend ActiveSupport::Concern | |
included do | |
singleton_class.alias_method_chain :bar, :meta | |
alias_method_chain :batz, :meta | |
end | |
module InstanceMethods | |
def batz_with_meta | |
"#{batz_without_meta}-metaskills" | |
end | |
end | |
module ClassMethods | |
def bar_with_meta | |
"#{bar_without_meta}-metaskills" | |
end | |
end | |
end | |
Foo.send :include, MetaSkills | |
Foo.bar # => "bar-metaskills" | |
Foo.new.batz # => "batz-metaskills" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment