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.



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

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

Instance Attribute Details

#mailerObject



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

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.



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

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.



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

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



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

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

#optsObject



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

def opts
  @opts ||= opts_default.dup
end

#opts=(options) ⇒ Object



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

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

#reset_optionsObject



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

def reset_options
  @opts = opts_default
  @smtp = smtp_default
end

#smtpObject



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

def smtp
  @smtp ||= smtp_default.dup
end

#smtp=(options) ⇒ Object



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

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