Class: Backup::Notifier::Mail

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/notifier/mail.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) ⇒ Mail

Instantiates a new Backup::Notifier::Mail object



61
62
63
64
65
66
67
# File 'lib/backup/notifier/mail.rb', line 61

def initialize(&block)
  load_defaults!

  instance_eval(&block) if block_given?

  set_defaults!
end

Instance Attribute Details

#addressObject

The address to use Example: smtp.gmail.com



30
31
32
# File 'lib/backup/notifier/mail.rb', line 30

def address
  @address
end

#authenticationObject

Authentication type Example: plain



52
53
54
# File 'lib/backup/notifier/mail.rb', line 52

def authentication
  @authentication
end

#domainObject

Your domain (if applicable) Example: mydomain.com



40
41
42
# File 'lib/backup/notifier/mail.rb', line 40

def domain
  @domain
end

#enable_starttls_autoObject

Automatically set TLS Example: true



57
58
59
# File 'lib/backup/notifier/mail.rb', line 57

def enable_starttls_auto
  @enable_starttls_auto
end

#fromObject

Sender and Receiver email addresses Examples:

sender   - [email protected]
receiver - [email protected]


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

def from
  @from
end

#mailObject

Container for the Mail object



14
15
16
# File 'lib/backup/notifier/mail.rb', line 14

def mail
  @mail
end

#modelObject

Container for the Model object



18
19
20
# File 'lib/backup/notifier/mail.rb', line 18

def model
  @model
end

#passwordObject

Username and Password (sender email’s credentials) Examples:

user_name - meskyanichi
password  - my_secret_password


47
48
49
# File 'lib/backup/notifier/mail.rb', line 47

def password
  @password
end

#portObject

The port to connect to Example: 587



35
36
37
# File 'lib/backup/notifier/mail.rb', line 35

def port
  @port
end

#toObject

Sender and Receiver email addresses Examples:

sender   - [email protected]
receiver - [email protected]


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

def to
  @to
end

#user_nameObject

Username and Password (sender email’s credentials) Examples:

user_name - meskyanichi
password  - my_secret_password


47
48
49
# File 'lib/backup/notifier/mail.rb', line 47

def user_name
  @user_name
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



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/backup/notifier/mail.rb', line 76

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