Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created December 4, 2011 17:59
Show Gist options
  • Save metaskills/1430833 to your computer and use it in GitHub Desktop.
Save metaskills/1430833 to your computer and use it in GitHub Desktop.
#!/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