Skip to content

Instantly share code, notes, and snippets.

@marcgg
Created September 14, 2010 17:26
Show Gist options
  • Save marcgg/579420 to your computer and use it in GitHub Desktop.
Save marcgg/579420 to your computer and use it in GitHub Desktop.
class A
def something
puts "something in A"
end
end
module B
def self.included(klass)
klass.send :remove_method, :something
end
def something
puts "something in B"
end
end
a = A.new
a.something
A.send(:include, B)
a = A.new
a.something
# Displays:
# something in A
# something in B
@marcgg
Copy link
Author

marcgg commented Sep 14, 2010

Here I didn't really care about being able to access the old method, but you're right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment