class Backup::Notifier::FlowDock

Attributes

from_email[RW]

Which email the notification should appear from

from_name[RW]

Who the notification should appear from

source[RW]

source for message

subject[RW]

Subject for message

tags[RW]

tag message in inbox

token[RW]

The Flowdock API token

Public Class Methods

new(model, &block) click to toggle source
Calls superclass method Backup::Notifier::Base::new
# File lib/backup/notifier/flowdock.rb, line 35
def initialize(model, &block)
  super
  instance_eval(&block) if block_given?

  @subject        ||= default_subject
  @source         ||= default_source
  @tags           ||= []
end

Private Instance Methods

default_source() click to toggle source

set default source

# File lib/backup/notifier/flowdock.rb, line 92
def default_source
  "Backup #{ model.label }"
end
default_subject() click to toggle source

set default subject

# File lib/backup/notifier/flowdock.rb, line 97
def default_subject
  'Backup Notification'
end
default_tags(status) click to toggle source

set related tags

# File lib/backup/notifier/flowdock.rb, line 82
def default_tags(status)
  case status
  when :success then ['#BackupSuccess']
  when :warning then ['#BackupWarning']
  when :failure then ['#BackupFailure']
  end
end
notify!(status) click to toggle source

Notify the user of the backup operation results.

‘status` indicates one of the following:

‘:success` : The backup completed successfully. : Notification will be sent if `on_success` is `true`.

‘:warning` : The backup completed successfully, but warnings were logged. : Notification will be sent if `on_warning` or `on_success` is `true`.

‘:failure` : The backup operation failed. : Notification will be sent if `on_warning` or `on_success` is `true`.

# File lib/backup/notifier/flowdock.rb, line 63
def notify!(status)
  @tags += default_tags(status)
  send_message(message.call(model, status: status_data_for(status)))
end
send_message(msg) click to toggle source

Flowdock::Client will raise an error if unsuccessful.

# File lib/backup/notifier/flowdock.rb, line 69
def send_message(msg)
  client = Flowdock::Flow.new(
    :api_token => token, :source => source,
    :from => {:name => from_name, :address => from_email }
  )

  client.push_to_team_inbox(:subject => subject,
                            :content => msg,
                            :tags => tags,
                            :link => link )
end