class LaGear::Publisher

Attributes

exchange[RW]

Public Class Methods

serialize(msg) click to toggle source
# File lib/la_gear/publisher.rb, line 9
def self.serialize(msg)
  msg.to_json
end

Public Instance Methods

publish(msg, opts = {}) click to toggle source
Calls superclass method
# File lib/la_gear/publisher.rb, line 5
def publish(msg, opts = {})
  super(self.class.serialize(msg), opts)
end

Private Instance Methods

connected?() click to toggle source
# File lib/la_gear/publisher.rb, line 24
def connected?
  @bunny && @bunny.connected?
end
ensure_connection!() click to toggle source
# File lib/la_gear/publisher.rb, line 15
def ensure_connection!
  opts = { heartbeat: @opts[:heartbeat] }
  opts.merge!(vhost: @opts[:vhost]) if @opts[:vhost]
  @bunny = Bunny.new(@opts[:amqp_publish] || @opts[:amqp], opts)
  @bunny.start
  @channel = @bunny.create_channel
  @exchange = @channel.exchange(@opts[:exchange], @opts[:exchange_options])
end