Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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