Class: Sender
- Inherits:
-
Object
- Object
- Sender
- Defined in:
- lib/test_driven_lighting/sender.rb
Instance Method Summary collapse
- #close_connection ⇒ Object
-
#initialize(config) ⇒ Sender
constructor
A new instance of Sender.
- #message_send(status, type) ⇒ Object
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_connection ⇒ Object
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 status, type = Hash status: status, type: type @exchange.publish .to_json end |