Skip to content

Instantly share code, notes, and snippets.

@trshafer
Forked from jaredatron/include_clone.rb
Created August 25, 2011 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trshafer/1169678 to your computer and use it in GitHub Desktop.
Save trshafer/1169678 to your computer and use it in GitHub Desktop.
module One
def go
1
end
end
module Two
def go
2
end
end
obj = Module.new
obj.extend One
obj.extend Two
call = 0
puts "call #{call+=1}: #{obj.go}"
obj.extend One.clone
puts "call #{call+=1}: #{obj.go}"
obj.extend Two.clone
puts "call #{call+=1}: #{obj.go}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment