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.
21 22 23 24 |
# File 'lib/multiple_man/connection.rb', line 21 def initialize(channel) self.channel = channel self.topic = channel.topic(topic_name) end |
Instance Attribute Details
#topic ⇒ Object
Returns the value of attribute topic.
19 20 21 |
# File 'lib/multiple_man/connection.rb', line 19 def topic @topic end |
Class Method Details
.connect ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/multiple_man/connection.rb', line 8 def self.connect connection = Bunny.new(MultipleMan.configuration.connection) MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}" connection.start channel = connection.create_channel yield new(channel) if block_given? ensure channel.close if channel && channel.open? connection.close if connection && connection.open? end |
Instance Method Details
#topic_name ⇒ Object
26 27 28 |
# File 'lib/multiple_man/connection.rb', line 26 def topic_name MultipleMan.configuration.topic_name end |