Class: RabbitJobs::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit_jobs/publisher.rb,
lib/rabbit_jobs/publisher/amqp.rb,
lib/rabbit_jobs/publisher/base.rb,
lib/rabbit_jobs/publisher/sync.rb,
lib/rabbit_jobs/publisher/test.rb

Overview

Interface for publishing messages to amqp queues or testing queues.

Defined Under Namespace

Classes: Amqp, Base, Sync, Test

Class Method Summary collapse

Class Method Details

.modeObject



9
10
11
# File 'lib/rabbit_jobs/publisher.rb', line 9

def mode
  publisher_instance.class_name.underscore
end

.mode=(value) ⇒ Object

Allows to switch publisher implementations. You can use RJ.publisher.mode = :test in testing environment.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rabbit_jobs/publisher.rb', line 15

def mode=(value)
  @publisher_instance = case value.to_s
                        when 'amqp'
                          Amqp
                        when 'test'
                          Test
                        when 'sync'
                          Sync
                        else
                          fail ArgumentError, "value must be :amqp, :sync or :test. Passed: #{value.inspect}"
                        end
end