Parent

Methods

Class/Module Index [+]

Quicksearch

Backup::Notifier::Base

Attributes

notify_on_failure?[RW]

When set to true, the user will be notified by email when a backup process raises an exception before finishing

notify_on_success?[RW]

When set to true, the user will be notified by email when a backup process ends without raising any exceptions

notify_on_warning?[RW]

When set to true, the user will be notified by email when a backup process is successful, but has warnings

on_failure[RW]

When set to true, the user will be notified by email when a backup process raises an exception before finishing

on_success[RW]

When set to true, the user will be notified by email when a backup process ends without raising any exceptions

on_warning[RW]

When set to true, the user will be notified by email when a backup process is successful, but has warnings

Public Class Methods

new(model) click to toggle source

Called with super(model) from subclasses

# File lib/backup/notifier/base.rb, line 27
def initialize(model)
  @model = model
  load_defaults!

  @on_success = true if on_success.nil?
  @on_warning = true if on_warning.nil?
  @on_failure = true if on_failure.nil?
end

Public Instance Methods

perform!(failure = false) click to toggle source

Performs the notification Takes a flag to indicate that a failure has occured. (this is only set from Model#perform! in the event of an error) If this is the case it will set the 'action' to :failure. Otherwise, it will set the 'action' to either :success or :warning, depending on whether or not any warnings were sent to the Logger. It will then invoke the notify! method with the 'action', but only if the proper on_success, on_warning or on_failure flag is true.

# File lib/backup/notifier/base.rb, line 45
def perform!(failure = false)
  @template  = Backup::Template.new({:model => @model})

  action = false
  if failure
    action = :failure if notify_on_failure?
  else
    if notify_on_success? || (notify_on_warning? && Logger.has_warnings?)
      action = Logger.has_warnings? ? :warning : :success
    end
  end

  if action
    log!
    notify!(action)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.