Method renames to be consistent with change to resources.

This commit is contained in:
Bob Aman 2012-02-10 17:26:44 +03:00
parent 6c0359720c
commit 1a381ab963
3 changed files with 15 additions and 13 deletions

View File

@ -50,7 +50,7 @@ module Google
metaclass.send(:define_method, method_name) { resource } metaclass.send(:define_method, method_name) { resource }
end end
end end
self.methods.each do |method| self.discovered_methods.each do |method|
method_name = Google::INFLECTOR.underscore(method.name).to_sym method_name = Google::INFLECTOR.underscore(method.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) { method } metaclass.send(:define_method, method_name) { method }
@ -167,7 +167,7 @@ module Google
self.discovered_resources.each do |resource| self.discovered_resources.each do |resource|
resource.method_base = @method_base resource.method_base = @method_base
end end
self.methods.each do |method| self.discovered_methods.each do |method|
method.method_base = @method_base method.method_base = @method_base
end end
end end
@ -208,7 +208,7 @@ module Google
# #
# @return [Array] A list of {Google::APIClient::Resource} objects. # @return [Array] A list of {Google::APIClient::Resource} objects.
def discovered_resources def discovered_resources
return @resources ||= ( return @discovered_resources ||= (
(@discovery_document['resources'] || []).inject([]) do |accu, (k, v)| (@discovery_document['resources'] || []).inject([]) do |accu, (k, v)|
accu << Google::APIClient::Resource.new( accu << Google::APIClient::Resource.new(
self, self.method_base, k, v self, self.method_base, k, v
@ -223,8 +223,8 @@ module Google
# API. # API.
# #
# @return [Array] A list of {Google::APIClient::Method} objects. # @return [Array] A list of {Google::APIClient::Method} objects.
def methods def discovered_methods
return @methods ||= ( return @discovered_methods ||= (
(@discovery_document['methods'] || []).inject([]) do |accu, (k, v)| (@discovery_document['methods'] || []).inject([]) do |accu, (k, v)|
accu << Google::APIClient::Method.new(self, self.method_base, k, v) accu << Google::APIClient::Method.new(self, self.method_base, k, v)
accu accu
@ -249,7 +249,7 @@ module Google
def to_h def to_h
return @hash ||= (begin return @hash ||= (begin
methods_hash = {} methods_hash = {}
self.methods.each do |method| self.discovered_methods.each do |method|
methods_hash[method.id] = method methods_hash[method.id] = method
end end
self.discovered_resources.each do |resource| self.discovered_resources.each do |resource|

View File

@ -48,7 +48,7 @@ module Google
metaclass.send(:define_method, method_name) { resource } metaclass.send(:define_method, method_name) { resource }
end end
end end
self.methods.each do |method| self.discovered_methods.each do |method|
method_name = Google::INFLECTOR.underscore(method.name).to_sym method_name = Google::INFLECTOR.underscore(method.name).to_sym
if !self.respond_to?(method_name) if !self.respond_to?(method_name)
metaclass.send(:define_method, method_name) { method } metaclass.send(:define_method, method_name) { method }
@ -85,7 +85,7 @@ module Google
self.discovered_resources.each do |resource| self.discovered_resources.each do |resource|
resource.method_base = @method_base resource.method_base = @method_base
end end
self.methods.each do |method| self.discovered_methods.each do |method|
method.method_base = @method_base method.method_base = @method_base
end end
end end
@ -95,7 +95,7 @@ module Google
# #
# @return [Array] A list of {Google::APIClient::Resource} objects. # @return [Array] A list of {Google::APIClient::Resource} objects.
def discovered_resources def discovered_resources
return @resources ||= ( return @discovered_resources ||= (
(@discovery_document['resources'] || []).inject([]) do |accu, (k, v)| (@discovery_document['resources'] || []).inject([]) do |accu, (k, v)|
accu << Google::APIClient::Resource.new( accu << Google::APIClient::Resource.new(
@api, self.method_base, k, v @api, self.method_base, k, v
@ -109,8 +109,8 @@ module Google
# A list of methods available on this resource. # A list of methods available on this resource.
# #
# @return [Array] A list of {Google::APIClient::Method} objects. # @return [Array] A list of {Google::APIClient::Method} objects.
def methods def discovered_methods
return @methods ||= ( return @discovered_methods ||= (
(@discovery_document['methods'] || []).inject([]) do |accu, (k, v)| (@discovery_document['methods'] || []).inject([]) do |accu, (k, v)|
accu << Google::APIClient::Method.new(@api, self.method_base, k, v) accu << Google::APIClient::Method.new(@api, self.method_base, k, v)
accu accu
@ -126,7 +126,7 @@ module Google
def to_h def to_h
return @hash ||= (begin return @hash ||= (begin
methods_hash = {} methods_hash = {}
self.methods.each do |method| self.discovered_methods.each do |method|
methods_hash[method.id] = method methods_hash[method.id] = method
end end
self.discovered_resources.each do |resource| self.discovered_resources.each do |resource|

View File

@ -75,7 +75,9 @@ module Google
api_version_string = api_version_string =
Google::INFLECTOR.camelize(api.version).gsub('.', '_') Google::INFLECTOR.camelize(api.version).gsub('.', '_')
if Google::APIClient::Schema.const_defined?(api_name_string, false) if Google::APIClient::Schema.const_defined?(api_name_string, false)
api_name = Google::APIClient::Schema.const_get(api_name_string, false) api_name = Google::APIClient::Schema.const_get(
api_name_string, false
)
else else
api_name = Google::APIClient::Schema.const_set( api_name = Google::APIClient::Schema.const_set(
api_name_string, Module.new api_name_string, Module.new