Skip to content

Instantly share code, notes, and snippets.

@michaelklishin
Created July 9, 2011 14:12
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 michaelklishin/1073605 to your computer and use it in GitHub Desktop.
Save michaelklishin/1073605 to your computer and use it in GitHub Desktop.
module ALibrary
class ABaseClass
def quack
puts "quack"
end
end
end
class ASpecificClass < ALibrary::ABaseClass
def quack
# overriden version that needs to call ALibrary::ABaseClass#quack
end
end
# Same effect without barbarian monkey-patching:
module ABaseClassExtension
def quack
result = super
puts "after quack"
result
end
end
class AnotherSpecificClass < ALibrary::ABaseClass
include ABaseClassExtension
end
AnotherSpecificClass.new.quack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment