Rename 'resources' method due to conflict with one of the APIs.
This commit is contained in:
parent
772d3a7671
commit
5b45f8f351
|
@ -44,7 +44,7 @@ module Google
|
||||||
@document_base = Addressable::URI.parse(document_base)
|
@document_base = Addressable::URI.parse(document_base)
|
||||||
@discovery_document = discovery_document
|
@discovery_document = discovery_document
|
||||||
metaclass = (class <<self; self; end)
|
metaclass = (class <<self; self; end)
|
||||||
self.resources.each do |resource|
|
self.discovered_resources.each do |resource|
|
||||||
method_name = Google::INFLECTOR.underscore(resource.name).to_sym
|
method_name = Google::INFLECTOR.underscore(resource.name).to_sym
|
||||||
if !self.respond_to?(method_name)
|
if !self.respond_to?(method_name)
|
||||||
metaclass.send(:define_method, method_name) { resource }
|
metaclass.send(:define_method, method_name) { resource }
|
||||||
|
@ -164,7 +164,7 @@ module Google
|
||||||
# The new base URI to use for the service.
|
# The new base URI to use for the service.
|
||||||
def method_base=(new_method_base)
|
def method_base=(new_method_base)
|
||||||
@method_base = Addressable::URI.parse(new_method_base)
|
@method_base = Addressable::URI.parse(new_method_base)
|
||||||
self.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.methods.each do |method|
|
||||||
|
@ -207,7 +207,7 @@ module Google
|
||||||
# API.
|
# API.
|
||||||
#
|
#
|
||||||
# @return [Array] A list of {Google::APIClient::Resource} objects.
|
# @return [Array] A list of {Google::APIClient::Resource} objects.
|
||||||
def resources
|
def discovered_resources
|
||||||
return @resources ||= (
|
return @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(
|
||||||
|
@ -252,7 +252,7 @@ module Google
|
||||||
self.methods.each do |method|
|
self.methods.each do |method|
|
||||||
methods_hash[method.id] = method
|
methods_hash[method.id] = method
|
||||||
end
|
end
|
||||||
self.resources.each do |resource|
|
self.discovered_resources.each do |resource|
|
||||||
methods_hash.merge!(resource.to_h)
|
methods_hash.merge!(resource.to_h)
|
||||||
end
|
end
|
||||||
methods_hash
|
methods_hash
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Google
|
||||||
@name = resource_name
|
@name = resource_name
|
||||||
@discovery_document = discovery_document
|
@discovery_document = discovery_document
|
||||||
metaclass = (class <<self; self; end)
|
metaclass = (class <<self; self; end)
|
||||||
self.resources.each do |resource|
|
self.discovered_resources.each do |resource|
|
||||||
method_name = Google::INFLECTOR.underscore(resource.name).to_sym
|
method_name = Google::INFLECTOR.underscore(resource.name).to_sym
|
||||||
if !self.respond_to?(method_name)
|
if !self.respond_to?(method_name)
|
||||||
metaclass.send(:define_method, method_name) { resource }
|
metaclass.send(:define_method, method_name) { resource }
|
||||||
|
@ -82,7 +82,7 @@ module Google
|
||||||
# The new base URI to use for the resource.
|
# The new base URI to use for the resource.
|
||||||
def method_base=(new_method_base)
|
def method_base=(new_method_base)
|
||||||
@method_base = Addressable::URI.parse(new_method_base)
|
@method_base = Addressable::URI.parse(new_method_base)
|
||||||
self.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.methods.each do |method|
|
||||||
|
@ -94,7 +94,7 @@ module Google
|
||||||
# A list of sub-resources available on this resource.
|
# A list of sub-resources available on this resource.
|
||||||
#
|
#
|
||||||
# @return [Array] A list of {Google::APIClient::Resource} objects.
|
# @return [Array] A list of {Google::APIClient::Resource} objects.
|
||||||
def resources
|
def discovered_resources
|
||||||
return @resources ||= (
|
return @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(
|
||||||
|
@ -129,7 +129,7 @@ module Google
|
||||||
self.methods.each do |method|
|
self.methods.each do |method|
|
||||||
methods_hash[method.id] = method
|
methods_hash[method.id] = method
|
||||||
end
|
end
|
||||||
self.resources.each do |resource|
|
self.discovered_resources.each do |resource|
|
||||||
methods_hash.merge!(resource.to_h)
|
methods_hash.merge!(resource.to_h)
|
||||||
end
|
end
|
||||||
methods_hash
|
methods_hash
|
||||||
|
|
Loading…
Reference in New Issue