let's try this again. don't convert datastore values to strings when copying, only dup things that are already Strings, see #2189, #2098, #2096

git-svn-id: file:///home/svn/framework3/trunk@9684 4d416f70-5f16-0410-b530-b9f4589650da
unstable
James Lee 2010-07-06 17:59:36 +00:00
parent 5df5991d95
commit 618b377d58
2 changed files with 11 additions and 17 deletions

View File

@ -65,7 +65,7 @@ class DataStore < Hash
# If the option has a default value, import it, but only if the
# datastore doesn't already have a value set for it.
if ((opt.default != nil) and (overwrite or self[name] == nil))
import_option(name, opt.default, true, imported_by)
import_option(name, opt.default.to_s, true, imported_by)
end
}
end
@ -116,12 +116,12 @@ class DataStore < Hash
#
def import_options_from_hash(option_hash, imported = true, imported_by = nil)
option_hash.each_pair { |key, val|
import_option(key, val, imported, imported_by)
import_option(key, val.to_s, imported, imported_by)
}
end
def import_option(key, val, imported=true, imported_by=nil)
self.store(key, val.to_s)
self.store(key, val)
@imported[key] = imported
@imported_by[key] = imported_by
@ -216,9 +216,14 @@ class DataStore < Hash
# Return a deep copy of this datastore.
#
def copy
copy = DataStore.new
copy = self.dup
self.keys.each do |k|
copy.import_option(k, self[k].to_s.dup, @imported[k], @imported_by[k])
if self[k].kind_of? String
v = self[k].dup
else
v = self[k]
end
copy.import_option(k, v, @imported[k], @imported_by[k])
end
copy
end
@ -292,17 +297,6 @@ class ModuleDataStore < DataStore
(@imported_by[key] == 'self')
end
#
# Return a deep copy of this datastore, just like the parent, but retaining
# the associated module.
#
def copy
copy = ModuleDataStore.new(@_module)
self.keys.each do |k|
copy.import_option(k, self[k].to_s.dup, @imported[k], @imported_by[k])
end
copy
end
end
end

View File

@ -152,7 +152,7 @@ class Module
#
def replicant
obj = self.class.new
obj.datastore = self.datastore.dup
obj.datastore = self.datastore.copy
obj.user_input = self.user_input
obj.user_output = self.user_output
obj.module_store = self.module_store