Skip to content

Instantly share code, notes, and snippets.

@sj26
Created October 12, 2010 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sj26/621629 to your computer and use it in GitHub Desktop.
Save sj26/621629 to your computer and use it in GitHub Desktop.
require 'active_support/all'
class Blah
def foo
'foo!'
end
end
module Things
def self.included(base)
base.alias_method_chain :foo, :things
end
def foo_with_things
foo_without_things.sub /(\W?)$/, " with things\\1"
end
end
Blah.new.foo
# => "foo!"
Blah.send :include, Things
Blah.new.foo
# => "foo with things!"
Blah.send :include, Things
Blah.new.foo
# => SystemStackError: stack level too deep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment