webmcp
view framework/env/slot/reset_all.lua @ 183:f7c1869b5b32
Reimplemented json.export(...) function without recursion (incomplete yet)
| author | jbe | 
|---|---|
| date | Sat Aug 09 19:39:16 2014 +0200 (2014-08-09) | 
| parents | 09f749330d13 | 
| children | 78a2ae40c88e | 
 line source
     1 --[[--
     2 slot.reset_all{
     3   except =  except  -- Reset all slots, except slots named in this list
     4 }
     6 Calling this function resets all slots to be empty. An exclusion list may be passed to the function as named argument.
     8 --]]--
    10 function slot.reset_all(args)
    11   local saved = {}
    12   if args and args.except then
    13     for i, key in ipairs(args.except) do
    14       saved[key] = slot._data[key]
    15     end
    16   end
    17   slot._data = setmetatable({}, slot._data_metatable)
    18   if saved then
    19     for key, value in pairs(saved) do
    20       slot._data[key] = value
    21     end
    22   end
    23 end
