Class: AceClient::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ace-client/base.rb

Direct Known Subclasses

Query2, Query4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ace-client/base.rb', line 18

def initialize(options)
  @access_key_id = options[:access_key_id]
  @secret_access_key = options[:secret_access_key]
  @endpoint = options[:endpoint]
  @http_proxy = options[:http_proxy]
  @http_method = options[:http_method] || :post
  @use_ssl = options[:use_ssl] || true
  @version = options[:version]
  @path = options[:path] || '/'
  @user_agent = options[:user_agent]
  set_http_proxy
end

Instance Attribute Details

#access_key_idObject

Returns the value of attribute access_key_id.



8
9
10
# File 'lib/ace-client/base.rb', line 8

def access_key_id
  @access_key_id
end

#endpointObject

Returns the value of attribute endpoint.



10
11
12
# File 'lib/ace-client/base.rb', line 10

def endpoint
  @endpoint
end

#http_methodObject

Returns the value of attribute http_method.



12
13
14
# File 'lib/ace-client/base.rb', line 12

def http_method
  @http_method
end

#http_proxyObject

Returns the value of attribute http_proxy.



11
12
13
# File 'lib/ace-client/base.rb', line 11

def http_proxy
  @http_proxy
end

#last_responseObject

Returns the value of attribute last_response.



14
15
16
# File 'lib/ace-client/base.rb', line 14

def last_response
  @last_response
end

#last_response_timeObject

Returns the value of attribute last_response_time.



15
16
17
# File 'lib/ace-client/base.rb', line 15

def last_response_time
  @last_response_time
end

#secret_access_keyObject

Returns the value of attribute secret_access_key.



9
10
11
# File 'lib/ace-client/base.rb', line 9

def secret_access_key
  @secret_access_key
end

#use_sslObject

Returns the value of attribute use_ssl.



13
14
15
# File 'lib/ace-client/base.rb', line 13

def use_ssl
  @use_ssl
end

#user_agentObject

Returns the value of attribute user_agent.



16
17
18
# File 'lib/ace-client/base.rb', line 16

def user_agent
  @user_agent
end

Instance Method Details

#record_responseObject



38
39
40
41
42
43
# File 'lib/ace-client/base.rb', line 38

def record_response
  start_time = Time.now
  @last_response = yield
  @last_response_time = Time.now - start_time
  @last_response
end

#set_http_proxyObject



31
32
33
34
35
36
# File 'lib/ace-client/base.rb', line 31

def set_http_proxy
  if @http_proxy
    uri = URI.parse(@http_proxy)
    self.class.http_proxy(uri.host, uri.port)
  end
end