From 0490dce7900c65fd22daca163356c499fc527c42 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 24 Mar 2014 23:03:02 +0200 Subject: persistence: rename variable --- aconf/persistence/init.lua | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'aconf/persistence') diff --git a/aconf/persistence/init.lua b/aconf/persistence/init.lua index 991776a..c1398fa 100644 --- a/aconf/persistence/init.lua +++ b/aconf/persistence/init.lua @@ -45,30 +45,32 @@ function DataStore:get(path) local backend, comps = self:split_path(path) local top = topology(path) - local res = backend:get(comps, top) + local value = backend:get(comps, top) if top then local t = top.type - if t and res ~= nil then - local atype = type(res) + if t and value ~= nil then + local atype = type(value) if t == 'table' then assert(atype == 'table') else assert(atype ~= 'table') - if t == 'string' then res = tostring(res) - elseif t == 'number' then res = tonumber(res) + if t == 'string' then value = tostring(value) + elseif t == 'number' then value = tonumber(value) elseif t == 'boolean' then - if atype == 'string' then res = res:lower() end - if res == 1 or contains({'1', 't', 'true', 'y', 'yes'}, res) then - res = true - elseif res == 0 or contains( - {'0', 'f', 'false', 'n', 'no'}, res + if atype == 'string' then value = value:lower() end + if value == 1 or contains( + {'1', 't', 'true', 'y', 'yes'}, value + ) then + value = true + elseif value == 0 or contains( + {'0', 'f', 'false', 'n', 'no'}, value ) then - res = false - else res = res and true or false end + value = false + else value = value and true or false end elseif contains({'binary', 'reference'}, t) then assert(atype == 'string') @@ -78,7 +80,7 @@ function DataStore:get(path) end end - return util.copy(res), self.mod_time[path] or 0 + return util.copy(value), self.mod_time[path] or 0 end function DataStore:_set_multiple(mods) -- cgit v1.2.3