Added API#schema_for_kind method to allow schema lookups by kind.

This commit is contained in:
Bob Aman 2011-08-05 14:43:56 -04:00
parent 1fa3fb25d9
commit 13d590631b
1 changed files with 17 additions and 0 deletions

View File

@ -150,6 +150,23 @@ module Google
)
end
##
# Returns a schema for a kind value.
#
# @return [Google::APIClient::Schema] The associated Schema object.
def schema_for_kind(kind)
api_name, schema_name = kind.split('#', 2)
if api_name != self.name
raise ArgumentError,
"The kind does not match this API. " +
"Expected '#{self.name}', got '#{api_name}'."
end
for k, v in self.schemas
return v if k.downcase == schema_name.downcase
end
return nil
end
##
# A list of resources available at the root level of this version of the
# API.