Module: Mumukit::Nuntius::Publisher

Defined in:
lib/mumukit/nuntius/publisher.rb

Class Method Summary collapse

Class Method Details

.method_missing(name, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/mumukit/nuntius/publisher.rb', line 11

def method_missing(name, *args, &block)
  if name.to_s.starts_with? 'publish_'
    queue_name = name.to_s.split('publish_').last
    publish queue_name, *args
  else
    super
  end
end

.publish(exchange_name, data, opts = {}) ⇒ Object



5
6
7
8
9
# File 'lib/mumukit/nuntius/publisher.rb', line 5

def publish(exchange_name, data, opts={})
  channel, exchange = Mumukit::Nuntius::Connection.start_channel(exchange_name)
  exchange.publish(data.to_json, opts.merge(persistent: true))
  channel.close
end