Class: Auger::Connection

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

Direct Known Subclasses

Cassandra, Cql, Dns, Http, Redis, Socket, Telnet

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ Connection

Returns a new instance of Connection.



12
13
14
15
16
# File 'lib/auger/connection.rb', line 12

def initialize(port)
  @options = {:port => port, :timeout => 5}
  @roles = []
  @requests = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, arg) ⇒ Object



28
29
30
# File 'lib/auger/connection.rb', line 28

def method_missing(method, arg)
  @options[method] = arg
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/auger/connection.rb', line 4

def connection
  @connection
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/auger/connection.rb', line 4

def options
  @options
end

#requestsObject

Returns the value of attribute requests.



4
5
6
# File 'lib/auger/connection.rb', line 4

def requests
  @requests
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/auger/connection.rb', line 4

def response
  @response
end

#roles(*names) ⇒ Object

Returns the value of attribute roles.



4
5
6
# File 'lib/auger/connection.rb', line 4

def roles
  @roles
end

Class Method Details

.load(port, &block) ⇒ Object



6
7
8
9
10
# File 'lib/auger/connection.rb', line 6

def self.load(port, &block)
  connection = new(port)
  connection.instance_eval(&block)
  connection
end

Instance Method Details

#do_open(server) ⇒ Object

call plugin open() and return plugin-specific connection object, or exception



33
34
35
36
37
38
39
40
# File 'lib/auger/connection.rb', line 33

def do_open(server)
  options = @options.merge(server.options)
  begin
    self.open(server.name, options)
  rescue => e
    e
  end
end

#timeout(secs) ⇒ Object

explicit method to override use of timeout.rb in modules



24
25
26
# File 'lib/auger/connection.rb', line 24

def timeout(secs)
  @options[:timeout] = secs
end