Created
July 9, 2011 14:12
-
-
Save michaelklishin/1073605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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