Created
May 11, 2021 16:39
-
-
Save armandofox/4b333ccb9cbf7f5de75c1ca9d94e7ad6 to your computer and use it in GitHub Desktop.
null_object_fix.rb
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 Config | |
def self.emailer | |
if email_disabled? then NullMailer else | |
if has_amiko? then Amiko else MailerMonkey end | |
end | |
end | |
end | |
class NullMailer | |
def initialize ; end | |
def send_email_to(*args) ; true ; end | |
end | |
def advertise_discount_for_movie | |
moviegoers = Moviegoer.interested_in(params[:movie_id]) | |
EmailList.new(Config.emailer).send_email_to(moviegoers) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment