Class: Backup::Notifier::Twitter

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/notifier/twitter.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#on_failure, #on_success

Instance Method Summary collapse

Methods inherited from Base

#log!

Methods included from Configuration::Helpers

#clear_defaults!, #getter_methods, #load_defaults!, #setter_methods

Constructor Details

#initialize(&block) ⇒ Twitter

Instantiates a new Backup::Notifier::Twitter object



29
30
31
32
33
34
35
# File 'lib/backup/notifier/twitter.rb', line 29

def initialize(&block)
  load_defaults!

  instance_eval(&block) if block_given?

  set_defaults!
end

Instance Attribute Details

#consumer_keyObject

Twitter consumer key credentials



21
22
23
# File 'lib/backup/notifier/twitter.rb', line 21

def consumer_key
  @consumer_key
end

#consumer_secretObject

Twitter consumer key credentials



21
22
23
# File 'lib/backup/notifier/twitter.rb', line 21

def consumer_secret
  @consumer_secret
end

#modelObject

Container for the Model object



17
18
19
# File 'lib/backup/notifier/twitter.rb', line 17

def model
  @model
end

#oauth_tokenObject

OAuth credentials



25
26
27
# File 'lib/backup/notifier/twitter.rb', line 25

def oauth_token
  @oauth_token
end

#oauth_token_secretObject

OAuth credentials



25
26
27
# File 'lib/backup/notifier/twitter.rb', line 25

def oauth_token_secret
  @oauth_token_secret
end

#twitter_clientObject

Container for the Twitter Client object



13
14
15
# File 'lib/backup/notifier/twitter.rb', line 13

def twitter_client
  @twitter_client
end

Instance Method Details

#perform!(model, exception = false) ⇒ Object

Performs the notification Takes an exception object that might’ve been created if an exception occurred. If this is the case it’ll invoke notify_failure!(exception), otherwise, if no error was raised, it’ll go ahead and notify_success!

If’ll only perform these if on_success is true or on_failure is true



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/backup/notifier/twitter.rb', line 44

def perform!(model, exception = false)
  @model = model

  if notify_on_success? and exception.eql?(false)
    log!
    notify_success!
  elsif notify_on_failure? and not exception.eql?(false)
    log!
    notify_failure!(exception)
  end
end