Class: MultipleMan::Connection
- Inherits:
-
Object
- Object
- MultipleMan::Connection
- Defined in:
- lib/multiple_man/connection.rb
Instance Attribute Summary collapse
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(channel) ⇒ Connection
constructor
A new instance of Connection.
- #topic_name ⇒ Object
Constructor Details
#initialize(channel) ⇒ Connection
Returns a new instance of Connection.
32 33 34 35 |
# File 'lib/multiple_man/connection.rb', line 32 def initialize(channel) self.channel = channel self.topic = channel.topic(topic_name) end |
Instance Attribute Details
#topic ⇒ Object
Returns the value of attribute topic.
30 31 32 |
# File 'lib/multiple_man/connection.rb', line 30 def topic @topic end |
Class Method Details
.connect ⇒ Object
23 24 25 26 27 28 |
# File 'lib/multiple_man/connection.rb', line 23 def self.connect channel = connection.create_channel yield new(channel) if block_given? ensure channel.close if channel end |
.connection ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/multiple_man/connection.rb', line 9 def self.connection @mutex.synchronize do # If the server has closed our connection, re-initialize @connection = nil if @connection && @connection.closed? @connection ||= begin connection = Bunny.new(MultipleMan.configuration.connection) MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}" connection.start connection end end end |
Instance Method Details
#topic_name ⇒ Object
37 38 39 |
# File 'lib/multiple_man/connection.rb', line 37 def topic_name MultipleMan.configuration.topic_name end |