Class: Mail::TestMailer

Inherits:
Object
  • Object
show all
Includes:
CheckDeliveryParams
Defined in:
lib/mail/network/delivery_methods/test_mailer.rb

Overview

The TestMailer is a bare bones mailer that does nothing. It is useful when you are testing.

It also provides a template of the minimum methods you require to implement if you want to make a custom mailer for Mail

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CheckDeliveryParams

#check_delivery_params

Constructor Details

#initialize(values) ⇒ TestMailer



33
34
35
# File 'lib/mail/network/delivery_methods/test_mailer.rb', line 33

def initialize(values)
  @settings = values.dup
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings



37
38
39
# File 'lib/mail/network/delivery_methods/test_mailer.rb', line 37

def settings
  @settings
end

Class Method Details

.deliveriesObject

Provides a store of all the emails sent with the TestMailer so you can check them.



14
15
16
# File 'lib/mail/network/delivery_methods/test_mailer.rb', line 14

def TestMailer.deliveries
  @@deliveries ||= []
end

.deliveries=(val) ⇒ Object

Allows you to over write the default deliveries store from an array to some other object. If you just want to clear the store, call TestMailer.deliveries.clear.

If you place another object here, please make sure it responds to:

  • << (message)

  • clear

  • length

  • size

  • and other common Array methods



29
30
31
# File 'lib/mail/network/delivery_methods/test_mailer.rb', line 29

def TestMailer.deliveries=(val)
  @@deliveries = val
end

Instance Method Details

#deliver!(mail) ⇒ Object



39
40
41
42
# File 'lib/mail/network/delivery_methods/test_mailer.rb', line 39

def deliver!(mail)
  check_delivery_params(mail)
  Mail::TestMailer.deliveries << mail
end