Added number, integer and boolean api 'kinds'.

This commit is contained in:
Manu Evans 2013-10-31 12:30:52 +10:00
parent 7ef0bf5bc8
commit 29ce69b9e7

View File

@ -636,6 +636,54 @@
end
--
-- Set a number value on an API field.
--
function api.setnumber(target, name, field, value)
local t = type(value)
if t ~= "number" then
error({ msg="expected number; got " .. t })
end
target = target.configset or target
target[name] = value
end
--
-- Set a integer value on an API field.
--
function api.setinteger(target, name, field, value)
local t = type(value)
if t ~= "number" then
error({ msg="expected number; got " .. t })
end
if math.floor(value) ~= value then
error({ msg="expected integer; got " .. tostring(value) })
end
target = target.configset or target
target[name] = value
end
--
-- Set a boolean value on an API field.
--
function api.setboolean(target, name, field, value)
local t = type(value)
if t ~= "boolean" then
error({ msg="expected boolean; got " .. t })
end
target = target.configset or target
target[name] = value
end
--
-- Start a new block of configuration settings.
--