Class: QueueConfig

Inherits:
Struct
  • Object
show all
Defined in:
lib/proletariat/queue_config.rb

Overview

Internal: Value object to hold RabbitMQ settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auto_deleteObject

Returns the value of attribute auto_delete

Returns:

  • (Object)

    the current value of auto_delete



2
3
4
# File 'lib/proletariat/queue_config.rb', line 2

def auto_delete
  @auto_delete
end

#routing_keysObject

Returns the value of attribute routing_keys

Returns:

  • (Object)

    the current value of routing_keys



2
3
4
# File 'lib/proletariat/queue_config.rb', line 2

def routing_keys
  @routing_keys
end

#worker_nameObject

Returns the value of attribute worker_name

Returns:

  • (Object)

    the current value of worker_name



2
3
4
# File 'lib/proletariat/queue_config.rb', line 2

def worker_name
  @worker_name
end

Instance Method Details

#queue_nameObject

Public: Create an underscored RabbitMQ queue name from the worker_name.

Examples

config = QueueConfig.new('ExampleWorker', ...)
config.queue_name
# => 'example_worker'

Returns the queue name as a String.



12
13
14
15
16
17
18
19
20
21
# File 'lib/proletariat/queue_config.rb', line 12

def queue_name
  @queue_name ||= begin
    worker_name
      .gsub(/::/, '/')
      .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr('-', '_')
      .downcase
  end
end