class MicroBunny::Subscriptions

Attributes

callback[R]
channel[R]
records[R]
topics[R]

Public Class Methods

new(channel, topics, records, &block) click to toggle source
# File lib/microbunny/subscriptions.rb, line 5
def initialize(channel, topics, records, &block)
  @channel = channel
  @topics = topics
  @records = records
  @callback = block
end

Public Instance Methods

create() click to toggle source
# 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

Private Instance Methods

all(topics) click to toggle source
# File lib/microbunny/subscriptions.rb, line 24
def all(topics)
  Array(topics).flatten.map(&:to_sym)
end
create_exchange(topic) click to toggle source
# File lib/microbunny/subscriptions.rb, line 28
def create_exchange(topic)
  channel.topic(topic)
end