Sha256: 49e2bcb7adce258c05ef4a4389a9ee697259cadd4c83663049a8cb3e8659db58

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

require 'monkey_mail/version'
require 'monkey_mail/mailer'
require 'monkey_mail/clients/mailgun_client'
require 'monkey_mail/clients/mandrill_client'
require 'monkey_mail/delivery_worker'

module MonkeyMail
  Configuration = Struct.new(
    :provider, :api_key, :domain, :delivery_method, :default_mail_parameters,
    keyword_init: true
  )

  module_function

  def configuration
    @configuration ||= Configuration.new(
      delivery_method: :default,
      default_mail_parameters: {}
    )
  end

  def configure
    yield configuration
  end

  def client
    @client ||= __send__("#{configuration.provider}_client")
  end

  def mandrill_client
    MonkeyMail::Clients::MandrillClient.new(configuration.api_key)
  end

  def mailgun_client
    MonkeyMail::Clients::MailgunClient.new(configuration.api_key, configuration.domain)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
monkey-mail-0.1.1 lib/monkey_mail.rb
monkey-mail-0.1.0 lib/monkey_mail.rb