Skip to content

Instantly share code, notes, and snippets.

@rachidcalazans
Created August 15, 2018 11:52
Show Gist options
  • Save rachidcalazans/dfad467719269db07faa9cff749bdedb to your computer and use it in GitHub Desktop.
Save rachidcalazans/dfad467719269db07faa9cff749bdedb to your computer and use it in GitHub Desktop.
Example I for the Post - Design Patterns in Ruby - Strategy - Part I
EmailStrategy = Struct.new(:from) do
def notify(context)
context.receivers.each { |receiver| push(to: receiver.email, subject: context.subject_msg, content: context.content_msg) }
end
private
def push(to:, subject:, content:)
# Call third lib to send email
# Using the :from too.
puts "Notifying through email Strategy. From: #{from}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment