Skip to content

Instantly share code, notes, and snippets.

@rachidcalazans
Created August 15, 2018 11:53
Show Gist options
  • Save rachidcalazans/4a9e376743266c0d3b1613f55db48322 to your computer and use it in GitHub Desktop.
Save rachidcalazans/4a9e376743266c0d3b1613f55db48322 to your computer and use it in GitHub Desktop.
Example I for the Post - Design Patterns in Ruby - Strategy - Part I
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