Class: MnoEnterprise::MailAdapters::Adapter Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/mno_enterprise/mail_adapters/adapter.rb

Overview

This class is abstract.

Subclass and override #client and #deliver to implement a custom Mailer Adapter.

Class Method Summary collapse

Class Method Details

.base_deliveriesArray

Note:

Only used for testing

Store the list of emails that are pending to be sent.

Examples:

expect { some_action }.to change(Adapter.base_deliveries,:count).by(1)

Returns:

  • (Array)


14
15
16
# File 'lib/mno_enterprise/mail_adapters/adapter.rb', line 14

def base_deliveries
  @base_deliveries ||= []
end

.clientObject

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/mno_enterprise/mail_adapters/adapter.rb', line 26

def client
  raise NotImplementedError
end

.deliver(template, from, to, vars = {}, opts = {}) ⇒ Object

Send a template

Parameters:

  • template (String)

    the immutable name of the template to send

  • from (Hash)

    a hash describing the sender

  • to (Array, Hash)

    an array or hash describing the recipient

  • vars (Hash) (defaults to: {})

    substitution variables

  • opts (Hash) (defaults to: {})

    additional parameters to pass to the client

Options Hash (from):

  • :name (String)

    optional from name to be used

  • :email (String)

    the sender email address

Options Hash (to):

  • :name (String)

    optional recipient name

  • :email (String)

    the recipient email address

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/mno_enterprise/mail_adapters/adapter.rb', line 45

def deliver(template,from,to,vars = {},opts = {})
  raise NotImplementedError
end

.test?Boolean

Check whether mailers are in test mode or not. Emails should not be sent in test mode.

Returns:

  • (Boolean)


22
23
24
# File 'lib/mno_enterprise/mail_adapters/adapter.rb', line 22

def test?
  (Rails.configuration.action_mailer.delivery_method || '').to_sym == :test
end