Class: Alerter::MessageDispatcher
- Inherits:
-
Object
- Object
- Alerter::MessageDispatcher
- Defined in:
- lib/alerter/message_dispatcher.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#recipients ⇒ Object
readonly
Returns the value of attribute recipients.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(message, recipients) ⇒ MessageDispatcher
constructor
A new instance of MessageDispatcher.
Constructor Details
#initialize(message, recipients) ⇒ MessageDispatcher
Returns a new instance of MessageDispatcher.
12 13 14 |
# File 'lib/alerter/message_dispatcher.rb', line 12 def initialize(, recipients) @message, @recipients = , recipients end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/alerter/message_dispatcher.rb', line 10 def @message end |
#recipients ⇒ Object (readonly)
Returns the value of attribute recipients.
10 11 12 |
# File 'lib/alerter/message_dispatcher.rb', line 10 def recipients @recipients end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/alerter/message_dispatcher.rb', line 16 def call return false unless (Alerter.notification_method - Alerter.available_notification_methods).empty? # array subtraction to see if notification methods are in the available list Alerter.notification_method.each do |method| case method when 'email' if Alerter.mailer_wants_array send_email(filtered_recipients(method)) else filtered_recipients(method).each do |recipient| send_email(recipient) if recipient.notification_methods(.notification_type).include?(method) && recipient.email.present? end end when 'none', 'ios_push', 'android_push', 'sms', 'twitter' else raise MethodNotImplemented.new(method) end end end |