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, ConfigurationError, Error, Mailer, MandrillValidationError, MessageError, Railtie, RecipientDataError, VariableError, VariableNotSetError, Worker
Constant Summary
collapse
- VERSION =
'0.2.7'
- @@lock =
Mutex.new
Class Method Summary
collapse
Class Method Details
.adapter ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/mandrill_queue.rb', line 37
def self.adapter
@@lock.synchronize do
@_adapter ||= begin
unless adapter = configuration.adapter
adapter = :resque if defined(::Resque)
adapter = :sidekiq if defined(::Sidekiq)
if adapter.nil?
raise RuntimeError, <<-TXT.strip.tr("\t", '')
Worker adapter was not configured and cannot be determined.
Please include a worker gem in your Gemfile. Resque and Sidekiq are supported.
TXT
end
end
load_adapter(adapter)
end
end
end
|
.adapter=(adapter) ⇒ Object
55
56
57
|
# File 'lib/mandrill_queue.rb', line 55
def self.adapter=(adapter)
@_adapter = adapter.nil? ? nil : load_adapter(adapter)
end
|
.configuration ⇒ Object
10
11
12
|
# File 'lib/mandrill_queue.rb', line 10
def self.configuration
@configuration ||= Configuration.new(defaults)
end
|
14
15
16
17
|
# File 'lib/mandrill_queue.rb', line 14
def self.configure
yield configuration
self
end
|
.defaults ⇒ Object
19
20
21
22
23
24
|
# File 'lib/mandrill_queue.rb', line 19
def self.defaults
{
message_defaults: {},
adapter: :resque
}
end
|
.eager_load! ⇒ Object
59
60
61
|
# File 'lib/mandrill_queue.rb', line 59
def self.eager_load!
end
|
.load_adapter(adapter) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/mandrill_queue.rb', line 26
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
63
64
65
66
67
|
# File 'lib/mandrill_queue.rb', line 63
def self.reset_config(&block)
self.adapter = nil
@configuration = nil
configure(&block) if block_given?
end
|