class Backup::Notifier::Twitter

Attributes

consumer_key[RW]

Twitter consumer key credentials

consumer_secret[RW]

Twitter consumer key credentials

oauth_token[RW]

OAuth credentials

oauth_token_secret[RW]

OAuth credentials

Public Class Methods

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

Private Instance Methods

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/twitter.rb, line 39
def notify!(status)
  send_message(message.call(model, :status => status_data_for(status)))
end
send_message(message) click to toggle source

Twitter::Client will raise an error if unsuccessful.

# File lib/backup/notifier/twitter.rb, line 44
def send_message(message)
  client = ::Twitter::REST::Client.new do |config|
    config.consumer_key        = @consumer_key
    config.consumer_secret     = @consumer_secret
    config.access_token        = @oauth_token
    config.access_token_secret = @oauth_token_secret
  end

  client.update(message)
end