From 1632e98a05f8b50ddb7eee75cba0645ea099497b Mon Sep 17 00:00:00 2001 From: Bob Aman Date: Wed, 22 Feb 2012 15:09:35 +0300 Subject: [PATCH] Patch to solve Ruby 1.8.7 incompatibility. --- lib/google/api_client/discovery/schema.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/google/api_client/discovery/schema.rb b/lib/google/api_client/discovery/schema.rb index f3499ebdc..cec0db8cc 100644 --- a/lib/google/api_client/discovery/schema.rb +++ b/lib/google/api_client/discovery/schema.rb @@ -74,22 +74,26 @@ module Google Google::INFLECTOR.camelize(api.name) api_version_string = Google::INFLECTOR.camelize(api.version).gsub('.', '_') - if Google::APIClient::Schema.const_defined?(api_name_string, false) + # This is for compatibility with Ruby 1.8.7. + # TODO(bobaman) Remove this when we eventually stop supporting 1.8.7. + args = [] + args << false if Class.method(:const_defined?).arity != 1 + if Google::APIClient::Schema.const_defined?(api_name_string, *args) api_name = Google::APIClient::Schema.const_get( - api_name_string, false + api_name_string, *args ) else api_name = Google::APIClient::Schema.const_set( api_name_string, Module.new ) end - if api_name.const_defined?(api_version_string, false) - api_version = api_name.const_get(api_version_string, false) + if api_name.const_defined?(api_version_string, *args) + api_version = api_name.const_get(api_version_string, *args) else api_version = api_name.const_set(api_version_string, Module.new) end - if api_version.const_defined?(schema_name, false) - schema_class = api_version.const_get(schema_name, false) + if api_version.const_defined?(schema_name, *args) + schema_class = api_version.const_get(schema_name, *args) end end