Last active
December 25, 2015 03:09
-
-
Save bruno-/6908044 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
class SmsNotifier | |
# We want to reuse code from this class, | |
# and we try to do that by using inheritance. | |
def notify! | |
# texting magic happens here | |
end | |
end | |
class ReportGenerator < SmsNotifier | |
# Send text messages when the report is done - no problem | |
def report_done_hook | |
notify! | |
end | |
end | |
class ReportArchiver < ActiveRecord::Base | |
# Oops! this object already has a superclass! | |
# How do you reuse the code now? | |
def report_compressed_hook | |
# notify! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment