Class: Shoryuken::Polling::QueueConfiguration
- Inherits:
-
Struct
- Object
- Struct
- Shoryuken::Polling::QueueConfiguration
- Defined in:
- lib/shoryuken/polling/queue_configuration.rb
Overview
Configuration object representing a queue and its associated options.
This class encapsulates a queue name along with any polling-specific options or metadata. It provides a structured way to pass queue information between polling strategies and the message fetching system.
The class extends Struct to provide attribute accessors for name and options while adding custom behavior for equality comparison and string representation.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the queue.
-
#options ⇒ Hash
readonly
Additional options or metadata for the queue.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compares this configuration with another object for equality.
-
#hash ⇒ Integer
Generates a hash value based on the queue name.
-
#to_s ⇒ String
Returns a string representation of the queue configuration.
Instance Attribute Details
#name ⇒ String (readonly)
The name of the queue
32 33 34 |
# File 'lib/shoryuken/polling/queue_configuration.rb', line 32 def name @name end |
#options ⇒ Hash (readonly)
Additional options or metadata for the queue
32 33 34 |
# File 'lib/shoryuken/polling/queue_configuration.rb', line 32 def @options end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compares this configuration with another object for equality.
Two QueueConfiguration objects are equal if they have the same name and options. For convenience, a configuration with empty options can also be compared directly with a string queue name.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/shoryuken/polling/queue_configuration.rb', line 64 def ==(other) case other when String if .empty? name == other else false end else super end end |
#hash ⇒ Integer
Generates a hash value based on the queue name.
This method ensures that QueueConfiguration objects can be used as hash keys and that configurations with the same queue name will have the same hash value regardless of their options.
40 41 42 |
# File 'lib/shoryuken/polling/queue_configuration.rb', line 40 def hash name.hash end |
#to_s ⇒ String
Returns a string representation of the queue configuration.
For configurations with empty options, returns just the queue name. For configurations with options, returns a detailed representation showing both the name and the options hash.
94 95 96 97 98 99 100 |
# File 'lib/shoryuken/polling/queue_configuration.rb', line 94 def to_s if &.empty? name else "#<QueueConfiguration #{name} options=#{.inspect}>" end end |