Class: Aliyun::Services::Base
- Inherits:
-
Object
- Object
- Aliyun::Services::Base
show all
- Defined in:
- lib/aliyun/services/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
17
18
19
20
|
# File 'lib/aliyun/services/base.rb', line 17
def initialize(options)
self.access_key_id = options[:access_key_id]
self.access_key_secret = options[:access_key_secret]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/aliyun/services/base.rb', line 22
def method_missing(method, *args, &block)
if service_actions.include?(action = method.to_sym)
params = args[0].nil? ? {} : args[0]
send_request(action, params)
else
super
end
end
|
Instance Attribute Details
#access_key_id ⇒ Object
Returns the value of attribute access_key_id.
15
16
17
|
# File 'lib/aliyun/services/base.rb', line 15
def access_key_id
@access_key_id
end
|
#access_key_secret ⇒ Object
Returns the value of attribute access_key_secret.
15
16
17
|
# File 'lib/aliyun/services/base.rb', line 15
def access_key_secret
@access_key_secret
end
|
Instance Method Details
#api_version ⇒ Object
55
56
57
|
# File 'lib/aliyun/services/base.rb', line 55
def api_version
service_definition[:version]
end
|
#base_url ⇒ Object
31
32
33
|
# File 'lib/aliyun/services/base.rb', line 31
def base_url
"#{request_schema}://#{request_host}"
end
|
#http_method ⇒ Object
63
64
65
|
# File 'lib/aliyun/services/base.rb', line 63
def http_method
'GET'
end
|
#name ⇒ Object
39
40
41
|
# File 'lib/aliyun/services/base.rb', line 39
def name
self.class::NAME
end
|
#request_host ⇒ Object
43
44
45
|
# File 'lib/aliyun/services/base.rb', line 43
def request_host
service_definition[:host]
end
|
#request_schema ⇒ Object
47
48
49
|
# File 'lib/aliyun/services/base.rb', line 47
def request_schema
service_definition[:schema] || Aliyun.config.default_schema || 'https'
end
|
51
52
53
|
# File 'lib/aliyun/services/base.rb', line 51
def response_format
service_definition[:format] || Aliyun.config.default_format || 'JSON'
end
|
#secure? ⇒ Boolean
35
36
37
|
# File 'lib/aliyun/services/base.rb', line 35
def secure?
request_schema == 'https'
end
|
#separator ⇒ Object
59
60
61
|
# File 'lib/aliyun/services/base.rb', line 59
def separator
"&"
end
|
#signature_method ⇒ Object
67
68
69
|
# File 'lib/aliyun/services/base.rb', line 67
def signature_method
Aliyun::SignatureMethods[service_definition[:signature_method]]
end
|