Class: Ragnar::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/ragnar/connector.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connectionObject

Store the connection for later retrieval



10
11
12
# File 'lib/ragnar/connector.rb', line 10

def connection
  @connection
end

.hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/ragnar/connector.rb', line 11

def host
  @host
end

.portObject

Returns the value of attribute port.



12
13
14
# File 'lib/ragnar/connector.rb', line 12

def port
  @port
end

Class Method Details

.connectObject

Pass connection options through to AMQP



15
16
17
18
19
20
# File 'lib/ragnar/connector.rb', line 15

def connect
  # backwards compatible code
  @host ||= ::Ragnar::Config.host
  @port ||= ::Ragnar::Config.port
  @connection = ::AMQP.connect({:host => @host, :port => @port})
end

.connected?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ragnar/connector.rb', line 22

def connected?
  @connection && @connection.connected?
end