lib/databasedotcom/client.rb in databasedotcom-1.1.6 vs lib/databasedotcom/client.rb in databasedotcom-1.1.7
- old
+ new
@@ -141,11 +141,11 @@
# The classes defined by materialize derive from Sobject, and have getters and setters defined for all the attributes defined by the associated Force.com Sobject.
def materialize(classnames)
classes = (classnames.is_a?(Array) ? classnames : [classnames]).collect do |clazz|
original_classname = clazz
clazz = original_classname[0,1].capitalize + original_classname[1..-1]
- unless module_namespace.const_defined?(clazz)
+ unless const_defined_in_module(module_namespace, clazz)
new_class = module_namespace.const_set(clazz, Class.new(Databasedotcom::Sobject::Sobject))
new_class.client = self
new_class.materialize(original_classname)
new_class
else
@@ -489,8 +489,12 @@
self.oauth_token = json["access_token"]
end
def query_org_id
query("select id from Organization")[0]["Id"]
+ end
+
+ def const_defined_in_module(mod, const)
+ mod.method(:const_defined?).arity == 1 ? mod.const_defined?(const) : mod.const_defined?(const, false)
end
end
end