The datastore is now case insensitive, but this may lead to some confusion... lets see :-)
git-svn-id: file:///home/svn/framework3/trunk@4398 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
0b42f16d1f
commit
ddb22785ee
|
@ -21,12 +21,28 @@ class DataStore < Hash
|
||||||
# directly.
|
# directly.
|
||||||
#
|
#
|
||||||
def []=(k, v)
|
def []=(k, v)
|
||||||
|
k = find_key_case(k)
|
||||||
@imported[k] = false
|
@imported[k] = false
|
||||||
@imported_by[k] = nil
|
@imported_by[k] = nil
|
||||||
|
|
||||||
super
|
super(k,v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Case-insensitive wrapper around hash lookup
|
||||||
|
#
|
||||||
|
def [](k)
|
||||||
|
super(find_key_case(k))
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Case-insensitive wrapper around store
|
||||||
|
#
|
||||||
|
def store(k,v)
|
||||||
|
super(find_key_case(k), v)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Updates a value in the datastore with the specified name, k, to the
|
# Updates a value in the datastore with the specified name, k, to the
|
||||||
# specified value, v. This update does not alter the imported status of
|
# specified value, v. This update does not alter the imported status of
|
||||||
|
@ -178,6 +194,24 @@ class DataStore < Hash
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
#
|
||||||
|
# Case-insensitive key lookup
|
||||||
|
#
|
||||||
|
def find_key_case(k)
|
||||||
|
|
||||||
|
# Scan each key looking for a match
|
||||||
|
self.each_key do |rk|
|
||||||
|
if (rk.downcase == k.downcase)
|
||||||
|
return rk
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fall through to the non-existent value
|
||||||
|
return k
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -938,7 +938,7 @@ class Core
|
||||||
print(
|
print(
|
||||||
"Usage: unset var1 var2 var3 ...\n\n" +
|
"Usage: unset var1 var2 var3 ...\n\n" +
|
||||||
"The unset command is used to unset one or more variables.\n" +
|
"The unset command is used to unset one or more variables.\n" +
|
||||||
"To flush all entires, specify 'all' as the variable name")
|
"To flush all entires, specify 'all' as the variable name\n")
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue