Class: Chasqui::SubscriptionBuilder
- Inherits:
-
Object
- Object
- Chasqui::SubscriptionBuilder
- Defined in:
- lib/chasqui/subscription_builder.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default_options ⇒ Hash
readonly
Default options for calls to #on.
-
#subscriptions ⇒ Chasqui::Subscriptions
readonly
The collection of currently registered subscriptions.
Instance Method Summary collapse
-
#on(channel, worker_or_proc, options = {}) ⇒ Object
Bind a worker to a channel.
Instance Attribute Details
#default_options ⇒ Hash (readonly)
Default options for calls to #on.
16 17 18 |
# File 'lib/chasqui/subscription_builder.rb', line 16 def end |
#subscriptions ⇒ Chasqui::Subscriptions (readonly)
The collection of currently registered subscriptions.
12 13 14 |
# File 'lib/chasqui/subscription_builder.rb', line 12 def subscriptions @subscriptions end |
Instance Method Details
#on(channel, worker_or_proc, options = {}) ⇒ Object
Bind a worker to a channel.
The broker will place jobs on the worker's queue for each event published to the given channel.
45 46 47 48 49 50 51 52 53 |
# File 'lib/chasqui/subscription_builder.rb', line 45 def on(channel, worker_or_proc, ={}) = .merge() worker = build_worker(channel, worker_or_proc, ) queue = full_queue_name(worker, ) set_queue_name(worker, queue) subscriptions.register Chasqui::Subscriber.new(channel, queue, worker) end |