Class: Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/test_driven_lighting/sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Sender

Returns a new instance of Sender.



5
6
7
8
9
# File 'lib/test_driven_lighting/sender.rb', line 5

def initialize config
  @connection = Bunny.new("amqp://#{config[:bunny_username]}:#{config[:bunny_password]}@#{config[:bunny_host]}").start
  @channel = @connection.create_channel
  @exchange = @channel.fanout('lighting.messages')
end

Instance Method Details

#close_connectionObject



16
17
18
# File 'lib/test_driven_lighting/sender.rb', line 16

def close_connection
  @connection.close
end

#message_send(status, type) ⇒ Object



11
12
13
14
# File 'lib/test_driven_lighting/sender.rb', line 11

def message_send status, type
  message = Hash status: status, type: type
  @exchange.publish message.to_json
end