Class: AbsenteeCamper::NotificationManager
- Inherits:
-
Object
- Object
- AbsenteeCamper::NotificationManager
- Includes:
- Logger
- Defined in:
- lib/absentee_camper/notification_manager.rb
Instance Method Summary collapse
-
#initialize(user_info) ⇒ NotificationManager
constructor
A new instance of NotificationManager.
- #send_notifications(message) ⇒ Object
Methods included from Logger
Constructor Details
#initialize(user_info) ⇒ NotificationManager
Returns a new instance of NotificationManager.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/absentee_camper/notification_manager.rb', line 5 def initialize(user_info) if user_info.is_a?(Hash) and user_info['notification_methods'] user_info['notification_methods'].each do |notifier, initialization_info| @notifiers = [].tap do |ary| ary << AbsenteeCamper.const_get("#{notifier}Notifier".to_sym).new(initialization_info) end end else # Everyone gets Email notifications if no other notifier is defined. # In this case, user_info is the user_id. log "No notification methods defined. Falling back to email notifications." @notifiers = [EmailNotifier.new(user_info)] end end |
Instance Method Details
#send_notifications(message) ⇒ Object
21 22 23 |
# File 'lib/absentee_camper/notification_manager.rb', line 21 def send_notifications() @notifiers.each { |notifier| notifier.notify } end |