Module: MandrillQueue

Defined in:
lib/mandrill_queue.rb,
lib/mandrill_queue/errors.rb,
lib/mandrill_queue/mailer.rb,
lib/mandrill_queue/worker.rb,
lib/mandrill_queue/logging.rb,
lib/mandrill_queue/message.rb,
lib/mandrill_queue/railtie.rb,
lib/mandrill_queue/version.rb,
lib/mandrill_queue/variables.rb,
lib/mandrill_queue/mandrill_api.rb,
lib/mandrill_queue/worker/hooks.rb,
lib/mandrill_queue/configuration.rb,
lib/mandrill_queue/message/images.rb,
lib/mandrill_queue/message/merge_vars.rb,
lib/mandrill_queue/message/recipients.rb,
lib/mandrill_queue/message/attachments.rb,
lib/mandrill_queue/message/recipient/data.rb,
lib/mandrill_queue/adapters/resque_adapter.rb,
lib/mandrill_queue/adapters/sidekiq_adapter.rb,
lib/mandrill_queue/message/recipient/helpers.rb,
lib/mandrill_queue/message/recipient/metadata.rb,
lib/mandrill_queue/message/recipient/variable.rb,
lib/rails/generators/mandrill_queue/worker_generator.rb,
lib/rails/generators/mandrill_queue/initializer_generator.rb

Defined Under Namespace

Modules: Adapters, Generators, Hooks, Logging, MandrillApi, Message, Variables Classes: Configuration, Error, Mailer, MandrillValidationError, MessageError, Railtie, RecipientDataError, VariableError, VariableNotSetError, Worker

Constant Summary collapse

VERSION =
'0.2.3'

Class Method Summary collapse

Class Method Details

.adapterObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mandrill_queue.rb', line 34

def self.adapter
  @_adapter ||= begin
    unless adapter = configuration.adapter
      adapter = :resque if defined(::Resque)
      adapter = :sidekiq if defined(::Sidekiq)
      if adapter.nil?
        raise RuntimeError, "          Worker adapter was not configured and cannot be determined.\n          Please include a worker gem in your Gemfile. Resque and Sidekiq are supported.\n        TXT\n      end\n    end\n    load_adapter(adapter)\n  end\nend\n".strip.tr("\t", '')

.adapter=(adapter) ⇒ Object



50
51
52
# File 'lib/mandrill_queue.rb', line 50

def self.adapter=(adapter)
  @_adapter = adapter.nil? ? nil : load_adapter(adapter)
end

.configurationObject



7
8
9
# File 'lib/mandrill_queue.rb', line 7

def self.configuration
  @configuration ||= Configuration.new(defaults)
end

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

Yields:



11
12
13
14
# File 'lib/mandrill_queue.rb', line 11

def self.configure
  yield configuration
  self
end

.defaultsObject



16
17
18
19
20
21
# File 'lib/mandrill_queue.rb', line 16

def self.defaults
  {
    message_defaults: {},
     adapter: :resque
  }
end

.eager_load!Object



54
55
56
# File 'lib/mandrill_queue.rb', line 54

def self.eager_load!
  # No autoloads
end

.load_adapter(adapter) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/mandrill_queue.rb', line 23

def self.load_adapter(adapter)
  if adapter.is_a?(Symbol)
    require "mandrill_queue/adapters/#{adapter}_adapter"
    "MandrillQueue::Adapters::#{adapter.to_s.camelize}Adapter".constantize.new
  elsif adapter.is_a?(String)
    adapter.constantize.new
  else
    adapter.try(:call) || adapter
  end
end

.reset_config(&block) ⇒ Object



58
59
60
61
62
# File 'lib/mandrill_queue.rb', line 58

def self.reset_config(&block)
   self.adapter = nil
  @configuration = nil
  configure(&block) if block_given?
end