Class: MicroBunny::Subscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/microbunny/subscriptions.rb

Instance Method Summary collapse

Constructor Details

#initialize(channel, topics, records, &block) ⇒ Subscriptions

Returns a new instance of Subscriptions.



5
6
7
8
9
10
# File 'lib/microbunny/subscriptions.rb', line 5

def initialize(channel, topics, records, &block)
  @channel = channel
  @topics = topics
  @records = records
  @callback = block
end

Instance Method Details

#createObject



12
13
14
15
16
17
18
# File 'lib/microbunny/subscriptions.rb', line 12

def create
  all(topics).each do |topic|
    exchange = create_exchange(topic)
    sub = Subscriber.new(channel, exchange, callback)
    records.empty? ? sub.topic(topic) : sub.records(records)
  end
end