Created
August 15, 2018 11:53
-
-
Save rachidcalazans/4a9e376743266c0d3b1613f55db48322 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
| IosStrategy = Struct.new(:app_token) do | |
| def notify(context) | |
| context.receivers.each { |receiver| push(user_token: receiver.token, title: context.subject_msg, content: context.content_msg) } | |
| end | |
| private | |
| def push(user_token:, title:, content:) | |
| # Call third lib to send iOS notification | |
| # Using the :app_token too. | |
| puts "Notifying through iOS Strategy. App token: #{app_token}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment