Class: MailLogger

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ MailLogger

Returns a new instance of MailLogger.



15
16
17
18
# File 'lib/maillogger.rb', line 15

def initialize(value)
  @@path ||= "./log/emails/"
  @settings = {}
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



20
21
22
# File 'lib/maillogger.rb', line 20

def settings
  @settings
end

Class Method Details

.delivery_method(clazz, options) ⇒ Object



6
7
8
9
# File 'lib/maillogger.rb', line 6

def self.delivery_method clazz,options
  @@clazz = clazz
  @@options = options
end

.log_path(path) ⇒ Object



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

def self.log_path path
  @@path = path
end

Instance Method Details

#deliver!(mail) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/maillogger.rb', line 22

def deliver!(mail)
  # run super
  @@clazz.new(@@options).deliver!(mail)
  # save to disk
  log(mail)
rescue => e
  # save to disk
  log(mail, true)
  raise e
end