Class: Sqs::Connection

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

Overview

Class responsible for handling connections to amazon hosts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Parameters:

options

Hash of options

Options:

access_key_id

access key id

secret_access_key

secret access key

use_ssl

optional, defaults to false

debug

optional, defaults to false

timeout

optional, for Net::HTTP



17
18
19
20
21
22
23
# File 'lib/sqs/connection.rb', line 17

def initialize(options = {})
  @access_key_id = options[:access_key_id]
  @secret_access_key = options[:secret_access_key]
  @use_ssl = options[:use_ssl] || false
  @debug = options[:debug]
  @timeout = options[:timeout]
end

Instance Attribute Details

#access_key_idObject

Returns the value of attribute access_key_id.



5
6
7
# File 'lib/sqs/connection.rb', line 5

def access_key_id
  @access_key_id
end

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/sqs/connection.rb', line 5

def debug
  @debug
end

#secret_access_keyObject

Returns the value of attribute secret_access_key.



5
6
7
# File 'lib/sqs/connection.rb', line 5

def secret_access_key
  @secret_access_key
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/sqs/connection.rb', line 5

def timeout
  @timeout
end

#use_sslObject Also known as: use_ssl?

Returns the value of attribute use_ssl.



5
6
7
# File 'lib/sqs/connection.rb', line 5

def use_ssl
  @use_ssl
end

Instance Method Details

#request(options) ⇒ Object

Makes request with given HTTP method, sets missing parameters, adds signature to request header and returns response object (Net::HTTPResponse)

Parameters:

options

hash of options

Options:

host

hostname to connecto to, optional, defaults to s3.amazonaws.com

path

path to send request to, required, throws ArgumentError if not given

params

parameters to encode in the request body, can be String or Hash

Returns:

Net::HTTPResponse object – response from remote server



39
40
41
42
43
44
45
46
# File 'lib/sqs/connection.rb', line 39

def request(options)
  host = options[:host] || HOST
  path = options[:path] or raise ArgumentError.new("no path given")
  params = options[:params]
  path = URI.escape(path)
  request = Net::HTTP::Post.new(path)
  send_request(host, request, params)
end