Module: GoogleApis::Api::Base::InstanceMethods
- Defined in:
- lib/google_apis/api/base/instance_methods.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 34
def method_missing(name, *args)
if resource = find(name)
Resource.new self, resource
else
super
end
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
6
7
8
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 6
def connection
@connection
end
|
#discovered_api ⇒ Object
Returns the value of attribute discovered_api.
6
7
8
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 6
def discovered_api
@discovered_api
end
|
Instance Method Details
#download(uri, to = nil) ⇒ Object
26
27
28
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 26
def download(uri, to = nil)
connection.download self.class, uri, to
end
|
#execute(api_method, *params) ⇒ Object
20
21
22
23
24
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 20
def execute(api_method, *params)
params[0] = correct_params(params[0])
params[0].reverse_merge! default_params(api_method)
connection.execute self.class, api_method, *params
end
|
#initialize(options = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 8
def initialize(options = {})
config, params = options.symbolize_keys.partition{|(k, v)| [:email_address, :private_key].include?(k)}.collect{|x| Hash[x]}
@connection = config.empty? ? GoogleApis.connection : GoogleApis::Connection.new(config)
raise Error, "Please ensure a Google API connection" unless @connection
params = correct_params(GoogleApis.config.merge(params))
@discovered_api = connection.discover_api self.class.api, self.class.version
@default_params = params.select{|k, v| self.class.default_parameters.include?(k)}
end
|
#inspect ⇒ Object
30
31
32
|
# File 'lib/google_apis/api/base/instance_methods.rb', line 30
def inspect
"#<#{self.class}:#{object_hexid} #{discovered_api.version}:[#{discovered_api.discovered_resources.collect(&:name).sort.join(",")}] {#{default_params.collect{|k, v| "#{k}:#{v.inspect}"}.join(",")}}>"
end
|