Created
May 11, 2021 16:39
-
-
Save armandofox/c9a3235dbf7be72738dcb4911ccb18e9 to your computer and use it in GitHub Desktop.
dip_example_2.rb
This file contains hidden or 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 EmailList | |
attr_reader :mailer | |
delegate :send_email, :to => :mailer | |
def initialize(mailer_type) | |
@mailer = mailer_type.new | |
end | |
end | |
# in RottenPotatoes EmailListController: | |
def advertise_discount_for_movie | |
moviegoers = Moviegoer.interested_in params[:movie_id] | |
mailer = if Config.has_amiko? then AmikoAdapter else MailerMonkey end | |
EmailList.new(mailer).send_email_to moviegoers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment