Module: Emailbutler

Extended by:
Emailbutler, Forwardable
Included in:
Emailbutler
Defined in:
lib/emailbutler.rb,
lib/emailbutler/dsl.rb,
lib/emailbutler/engine.rb,
lib/emailbutler/helpers.rb,
lib/emailbutler/version.rb,
lib/emailbutler/container.rb,
lib/emailbutler/configuration.rb,
lib/emailbutler/mailers/helpers.rb,
lib/emailbutler/webhooks/receiver.rb,
lib/emailbutler/adapters/active_record.rb,
lib/emailbutler/webhooks/mappers/resend.rb,
lib/emailbutler/webhooks/mappers/mailjet.rb,
lib/emailbutler/webhooks/mappers/smtp2go.rb,
app/controllers/emailbutler/ui_controller.rb,
lib/emailbutler/webhooks/mappers/mailtrap.rb,
lib/emailbutler/webhooks/mappers/mandrill.rb,
lib/emailbutler/webhooks/mappers/sendgrid.rb,
app/helpers/emailbutler/application_helper.rb,
app/controllers/emailbutler/webhooks_controller.rb,
app/controllers/emailbutler/application_controller.rb,
app/controllers/emailbutler/ui/messages_controller.rb,
lib/generators/emailbutler/active_record_generator.rb

Defined Under Namespace

Modules: Adapters, ApplicationHelper, Generators, Helpers, Mailers, Ui, Webhooks Classes: ApplicationController, Configuration, Container, DSL, Engine, Message, UiController, WebhooksController

Constant Summary collapse

VERSION =
'0.8.8'

Instance Method Summary collapse

Instance Method Details

#configurationObject

Public: Returns Emailbutler::Configuration instance.



33
34
35
36
37
38
# File 'lib/emailbutler.rb', line 33

def configuration
  return Emailbutler::Container.resolve(:configuration) if Emailbutler::Container.key?(:configuration)

  Emailbutler::Container.register(:configuration) { Configuration.new }
  Emailbutler::Container.resolve(:configuration)
end

#configure {|configuration| ... } ⇒ Object

Public: Configure emailbutler.

require 'emailbutler/adapters/active_record'

Emailbutler.configure do |config|
  config.adapter = Emailbutler::Adapters::ActiveRecord.new
  config.providers = %i[sendgrid]
end

Yields:



26
27
28
29
30
# File 'lib/emailbutler.rb', line 26

def configure
  yield configuration

  configuration.validate
end

#instanceObject

Public: Returns Emailbutler::DSL instance.



41
42
43
44
45
46
# File 'lib/emailbutler.rb', line 41

def instance
  return Emailbutler::Container.resolve(:instance) if Emailbutler::Container.key?(:instance)

  Emailbutler::Container.register(:instance) { DSL.new(configuration.adapter) }
  Emailbutler::Container.resolve(:instance)
end