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