Class: BackupDemon::Notifier
- Inherits:
-
Object
- Object
- BackupDemon::Notifier
- Defined in:
- lib/backup_demon/notifier.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(recepients) ⇒ Notifier
constructor
A new instance of Notifier.
- #mail(subject, &block) ⇒ Object
Constructor Details
#initialize(recepients) ⇒ Notifier
Returns a new instance of Notifier.
3 4 5 |
# File 'lib/backup_demon/notifier.rb', line 3 def initialize(recepients) @recepients = [recepients].flatten end |
Class Method Details
.alert(subject, &block) ⇒ Object
17 18 19 20 |
# File 'lib/backup_demon/notifier.rb', line 17 def self.alert(subject, &block) notifier = new(BackupDemon.config.recepients) notifier.mail(subject, &block) end |
Instance Method Details
#mail(subject, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/backup_demon/notifier.rb', line 7 def mail(subject, &block) if block_given? msg = yield @recepients.each do |recepient| `echo #{msg} | mail -s "#{subject}" #{recepient}` end end end |