Sha256: 151b4382b7ba450c8d63cc8f024321e809a18350806853a43c8020ba9549cdea

Contents?: true

Size: 1.61 KB

Versions: 12

Compression:

Stored size: 1.61 KB

Contents

module MnoEnterprise
  module MailAdapters
    # @abstract Subclass and override {#client} and {#deliver} to implement
    #   a custom Mailer Adapter.
    class Adapter
      class << self
        # Store the list of emails that are pending to be sent.
        # @note Only used for testing
        #
        # @example
        #   expect { some_action }.to change(Adapter.base_deliveries,:count).by(1)
        #
        # @return [Array]
        def base_deliveries
          @base_deliveries ||= []
        end

        # Check whether mailers are in test mode or not.
        # Emails should not be sent in test mode.
        #
        # @return [Boolean]
        def test?
          (Rails.configuration.action_mailer.delivery_method || '').to_sym == :test
        end

        def client
          raise NotImplementedError
        end

        # Send a template
        #
        # @param [String] template the immutable name of the template to send
        #
        # @param [Hash] from a hash describing the sender
        # @option from [String] :name optional from name to be used
        # @option from [String] :email the sender email address
        #
        # @param [Array, Hash] to an array or hash describing the recipient
        # @option to [String] :name optional recipient name
        # @option to [String] :email the recipient email address
        #
        # @param [Hash] vars substitution variables
        # @param [Hash] opts additional parameters to pass to the client
        #
        def deliver(template,from,to,vars = {},opts = {})
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mno-enterprise-core-3.4.0 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.3.3 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.3.2 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.2.1 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.3.1 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.3.0 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.2.0 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.1.4 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.1.3 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.1.2 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.1.1 lib/mno_enterprise/mail_adapters/adapter.rb
mno-enterprise-core-3.1.0 lib/mno_enterprise/mail_adapters/adapter.rb