Class: Surfliner::Mq::TopicConfig
- Inherits:
-
Object
- Object
- Surfliner::Mq::TopicConfig
- Defined in:
- lib/surfliner/mq/topic_config.rb
Overview
Encapsulates topic configuration
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The topic exchange to listen to.
-
#options ⇒ Hash
readonly
RabbitMQ topic options.
Class Method Summary collapse
-
.from_env(**options) ⇒ TopicConfig
Returns a default (environment-variable-based) configuration with the specified options.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether
otherrepresents the same configuration as this object. -
#eql?(other) ⇒ Boolean
Whether
otherrepresents the same configuration as this object. -
#hash ⇒ Integer
The hash value of this object.
-
#initialize(name:, options: {}) ⇒ TopicConfig
constructor
A new instance of TopicConfig.
Constructor Details
#initialize(name:, options: {}) ⇒ TopicConfig
Returns a new instance of TopicConfig.
13 14 15 16 |
# File 'lib/surfliner/mq/topic_config.rb', line 13 def initialize(name:, options: {}) @name = name @options = end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns The topic exchange to listen to.
6 7 8 |
# File 'lib/surfliner/mq/topic_config.rb', line 6 def name @name end |
#options ⇒ Hash (readonly)
Returns RabbitMQ topic options. (See Bunny::Channel#topic).
9 10 11 |
# File 'lib/surfliner/mq/topic_config.rb', line 9 def @options end |
Class Method Details
.from_env(**options) ⇒ TopicConfig
Returns a default (environment-variable-based) configuration with the specified options.
| Variable | Sample value | Description |
|---|---|---|
RABBITMQ_TOPIC |
surfliner.metadata |
RabbitMQ topic name |
52 53 54 55 56 57 |
# File 'lib/surfliner/mq/topic_config.rb', line 52 def from_env(**) TopicConfig.new( name: ENV.fetch("RABBITMQ_TOPIC"), options: ) end |
Instance Method Details
#==(other) ⇒ Boolean
Whether other represents the same configuration as this object.
Note that if name or options are modified, equality becomes unstable.
30 31 32 33 |
# File 'lib/surfliner/mq/topic_config.rb', line 30 def ==(other) return unless other.class == self.class other.name == name && other. == end |
#eql?(other) ⇒ Boolean
Whether other represents the same configuration as this object.
Note that if name or options are modified, equality becomes unstable.
22 23 24 |
# File 'lib/surfliner/mq/topic_config.rb', line 22 def eql?(other) self == other end |
#hash ⇒ Integer
The hash value of this object. Equal configurations will have equal hash values.
Note that if name or options are modified, the hash value becomes unstable.
38 39 40 |
# File 'lib/surfliner/mq/topic_config.rb', line 38 def hash [name, ].hash end |