Class: DoSnapshot::Mail

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

Overview

Shared mailer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mail

Returns a new instance of Mail.



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

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

Instance Attribute Details

#mailerObject



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

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

#opts_default=(value) ⇒ Object

Sets the attribute opts_default

Parameters:

  • value

    the value to set the attribute opts_default to.



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

def opts_default=(value)
  @opts_default = value
end

#smtp_default=(value) ⇒ Object

Sets the attribute smtp_default

Parameters:

  • value

    the value to set the attribute smtp_default to.



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

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



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

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

#optsObject



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

def opts
  @opts ||= opts_default.dup
end

#opts=(options) ⇒ Object



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

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

#reset_optionsObject



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

def reset_options
  @opts = opts_default
  @smtp = smtp_default
end

#smtpObject



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

def smtp
  @smtp ||= smtp_default.dup
end

#smtp=(options) ⇒ Object



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

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