This based on Database.rb, 0.0.5. As a quick summary: initialize @remote_to_local_map in initialize() and replace
"class.to_s ==" with "kind_of?".
Regards,
Dan
--- Database.orig Fri May 7 07:15:16 2004
+++ Database.rb Fri May 7 07:22:04 2004
@@ -93,6 +93,7 @@
@objects = {}
@changed = []
+ @remote_to_local_map = {}
set_autocommit
end
@@ -171,21 +172,21 @@
#
# Note that select'd currently operates outside of the local rollback cache.
def select(table, sql=nil)
- table = table.to_s if table.class.to_s == 'Symbol'
+ table = table.to_s if table.kind_of?(Symbol)
+ raise TypeError unless table.kind_of?(String)
+
results = []
- if table.class.to_s == 'String'
- if @remote_to_local_map.has_key?(table)
- table = self.class.const_get @remote_to_local_map[table]
- elsif KSDatabase.partial_to_complete_map.has_key?(table)
- table = self.class.const_get KSDatabase.partial_to_complete_map[table]
- else
- table = nil
- end
+ if @remote_to_local_map.has_key?(table)
+ table = self.class.const_get @remote_to_local_map[table]
+ elsif KSDatabase.partial_to_complete_map.has_key?(table)
+ table = self.class.const_get KSDatabase.partial_to_complete_map[table]
+ else
+ table = nil
end
# Todo: Make this exception clearer.
- unless table.class == Class
+ unless table.kind_of?(Class)
raise KSBadTable
end
@@ -379,7 +380,6 @@
table.const_set('Database', self)
table.all_fields
- @remote_to_local_map = {} unless @remote_to_local_map
@remote_to_local_map[remote_name] = local_name
KSDatabase.partial_to_complete_map[old_local_name] = local_name
addTable(local_name, table)
|