Allow updates to fallthrough to the global store just like reads

unstable
HD Moore 2012-02-29 01:40:54 -06:00
parent 4c39cfd98a
commit 7b40d8d819
1 changed files with 18 additions and 7 deletions

View File

@ -264,6 +264,7 @@ class ModuleDataStore < DataStore
# if we can't directly find it
#
def fetch(key)
key = find_key_case(key)
val = nil
val = super if(@imported_by[key] != 'self')
if (val.nil? and @_module and @_module.framework)
@ -277,15 +278,25 @@ class ModuleDataStore < DataStore
# Same as fetch
#
def [](key)
val = nil
val = super if(@imported_by[key] != 'self')
if (val.nil? and @_module and @_module.framework)
val = @_module.framework.datastore[key]
end
val = super if val.nil?
val
self.fetch(key)
end
#
# 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
# the value. This will directly update the global framework datastore if
# the value is still default in the local store.
#
def update_value(k, v)
k = find_key_case(k)
if @imported_by[k] =='self' and @_module and @_module.framework)
@_module.framework.datastore.update_value(k,v)
else
super(k,v)
end
end
#
# Was this entry actually set or just using its default
#