class Backup::Notifier::FlowDock
Attributes
from_email[RW]
Which email the notification should appear from
from_name[RW]
Who the notification should appear from
link[RW]
link for message
source[RW]
source for message
subject[RW]
Subject for message
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 33 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 89 def default_source "Backup #{model.label}" end
default_subject()
click to toggle source
set default subject
# File lib/backup/notifier/flowdock.rb, line 94 def default_subject "Backup Notification" 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 61 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 67 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