Module: Hutch::Consumer::ClassMethods
- Defined in:
- lib/hutch/consumer.rb
Instance Method Summary collapse
-
#consume(*routing_keys) ⇒ Object
Add one or more routing keys to the set of routing keys the consumer wants to subscribe to.
-
#queue_name ⇒ Object
The RabbitMQ queue name for the consumer.
-
#routing_keys ⇒ Object
Accessor for the consumer’s routing key.
Instance Method Details
#consume(*routing_keys) ⇒ Object
Add one or more routing keys to the set of routing keys the consumer wants to subscribe to.
14 15 16 |
# File 'lib/hutch/consumer.rb', line 14 def consume(*routing_keys) @routing_keys = self.routing_keys.union(routing_keys) end |
#queue_name ⇒ Object
The RabbitMQ queue name for the consumer. This is derived from the fully-qualified class name. Module separators are replaced with single colons, camelcased class names are converted to snake case.
21 22 23 24 |
# File 'lib/hutch/consumer.rb', line 21 def queue_name queue_name = self.name.gsub(/::/, ':') queue_name.gsub(/([^A-Z:])([A-Z])/) { "#{$1}_#{$2}" }.downcase end |
#routing_keys ⇒ Object
Accessor for the consumer’s routing key.
27 28 29 |
# File 'lib/hutch/consumer.rb', line 27 def routing_keys @routing_keys ||= Set.new end |