Class: DoSnapshot::Mail

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/do_snapshot/mail.rb

Overview

Shared mailer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#logger

Constructor Details

#initialize(options = {}) ⇒ Mail



15
16
17
# File 'lib/do_snapshot/mail.rb', line 15

def initialize(options = {})
  options.each { |key, option| send("#{key}=", option) }
end

Instance Attribute Details

#mailerObject



24
25
26
# File 'lib/do_snapshot/mail.rb', line 24

def mailer
  @mailer ||= Pony.method(:mail)
end

#opts_default=(value) ⇒ Object

Sets the attribute opts_default



13
14
15
# File 'lib/do_snapshot/mail.rb', line 13

def opts_default=(value)
  @opts_default = value
end

#smtp_default=(value) ⇒ Object

Sets the attribute smtp_default



13
14
15
# File 'lib/do_snapshot/mail.rb', line 13

def smtp_default=(value)
  @smtp_default = value
end

Instance Method Details

#notifyObject

Sending message via Hash params.

Options

–mail to:[email protected] from:[email protected] –smtp address:smtp.gmail.com user_name:someuser password:somepassword



52
53
54
55
56
57
# File 'lib/do_snapshot/mail.rb', line 52

def notify
  setup_notify
  logger.debug 'Sending e-mail notification.'
  # Look into your inbox :)
  mailer.call(opts)
end

#optsObject



32
33
34
# File 'lib/do_snapshot/mail.rb', line 32

def opts
  @opts ||= opts_default.dup
end

#opts=(options) ⇒ Object



42
43
44
45
46
# File 'lib/do_snapshot/mail.rb', line 42

def opts=(options)
  options.each_pair do |key, value|
    opts[key.to_sym] = value
  end if options
end

#reset_optionsObject



19
20
21
22
# File 'lib/do_snapshot/mail.rb', line 19

def reset_options
  @opts = opts_default
  @smtp = smtp_default
end

#smtpObject



28
29
30
# File 'lib/do_snapshot/mail.rb', line 28

def smtp
  @smtp ||= smtp_default.dup
end

#smtp=(options) ⇒ Object



36
37
38
39
40
# File 'lib/do_snapshot/mail.rb', line 36

def smtp=(options)
  options.each_pair do |key, value|
    smtp[key.to_sym] = value
  end if options
end