Class: MultipleMan::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/multiple_man/connection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Connection

Returns a new instance of Connection.



16
17
18
19
20
# File 'lib/multiple_man/connection.rb', line 16

def initialize
  init_connection!
  init_channel!
  self.topic = channel.topic(topic_name)
end

Instance Attribute Details

#topic ⇒ Object

Returns the value of attribute topic.



14
15
16
# File 'lib/multiple_man/connection.rb', line 14

def topic
  @topic
end

Class Method Details

.connect ⇒ Object



7
8
9
10
11
12
# File 'lib/multiple_man/connection.rb', line 7

def self.connect
  connection = new
  yield connection if block_given?
ensure
  connection.close! if connection
end

Instance Method Details

#close! ⇒ Object



26
27
28
29
# File 'lib/multiple_man/connection.rb', line 26

def close!
  channel.close if channel
  connection.close if connection
end

#topic_name ⇒ Object



22
23
24
# File 'lib/multiple_man/connection.rb', line 22

def topic_name
  MultipleMan.configuration.topic_name
end