Class: AbsenteeCamper::NotificationManager

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/absentee_camper/notification_manager.rb

Instance Method Summary collapse

Methods included from Logger

#log

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()
  if .is_a?(Hash) and ['notification_methods']
    ['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()]
  end
end

Instance Method Details

#send_notifications(message) ⇒ Object



21
22
23
# File 'lib/absentee_camper/notification_manager.rb', line 21

def send_notifications(message)
  @notifiers.each { |notifier| notifier.notify message }
end