class RabbitJobs::Publisher

Interface for publishing messages to amqp queues or testing queues.

Public Class Methods

mode() click to toggle source
# File lib/rabbit_jobs/publisher.rb, line 9
def mode
  publisher_instance.class_name.underscore
end
mode=(value) click to toggle source

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

# 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

Private Class Methods

publisher_instance() click to toggle source

Default publisher type is Amqp.

# File lib/rabbit_jobs/publisher.rb, line 33
def publisher_instance
  @publisher_instance || Amqp
end