Skip to content

Instantly share code, notes, and snippets.

@armandofox
Created May 11, 2021 16:39
Show Gist options
  • Save armandofox/c9a3235dbf7be72738dcb4911ccb18e9 to your computer and use it in GitHub Desktop.
Save armandofox/c9a3235dbf7be72738dcb4911ccb18e9 to your computer and use it in GitHub Desktop.
dip_example_2.rb
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