Created
August 15, 2018 11:52
-
-
Save rachidcalazans/dfad467719269db07faa9cff749bdedb to your computer and use it in GitHub Desktop.
Example I for the Post - Design Patterns in Ruby - Strategy - Part I
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
| 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