diff options
author | Kim Alvefur <zash@zash.se> | 2017-03-16 23:49:27 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-03-16 23:49:27 +0100 |
commit | 3e5d5895f9365fbecf497d9080f8f5705a3266a6 (patch) | |
tree | 5d9e9dfec7020f862dc40a4b872556e3661b5327 /core/moduleapi.lua | |
parent | 5b35a9ffb3c7d9cc46c10d788b1dd573f11b1688 (diff) | |
parent | a374056fa56185322141484732d963abdee02941 (diff) | |
download | prosody-3e5d5895f9365fbecf497d9080f8f5705a3266a6.tar.gz prosody-3e5d5895f9365fbecf497d9080f8f5705a3266a6.zip |
Merge 0.10->trunk
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r-- | core/moduleapi.lua | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 62c34031..e39fd026 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -214,7 +214,7 @@ function api:get_option(name, default_value) return value; end -function api:get_option_string(name, default_value) +function api:get_option_scalar(name, default_value) local value = self:get_option(name, default_value); if type(value) == "table" then if #value > 1 then @@ -222,6 +222,11 @@ function api:get_option_string(name, default_value) end value = value[1]; end + return value; +end + +function api:get_option_string(name, default_value) + local value = self:get_option_scalar(name, default_value); if value == nil then return nil; end @@ -229,13 +234,7 @@ function api:get_option_string(name, default_value) end function api:get_option_number(name, ...) - local value = self:get_option(name, ...); - if type(value) == "table" then - if #value > 1 then - self:log("error", "Config option '%s' does not take a list, using just the first item", name); - end - value = value[1]; - end + local value = self:get_option_scalar(name, ...); local ret = tonumber(value); if value ~= nil and ret == nil then self:log("error", "Config option '%s' not understood, expecting a number", name); @@ -244,13 +243,7 @@ function api:get_option_number(name, ...) end function api:get_option_boolean(name, ...) - local value = self:get_option(name, ...); - if type(value) == "table" then - if #value > 1 then - self:log("error", "Config option '%s' does not take a list, using just the first item", name); - end - value = value[1]; - end + local value = self:get_option_scalar(name, ...); if value == nil then return nil; end |