Software /
code /
prosody
Diff
core/moduleapi.lua @ 7982:e30b0cbed472
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 16 Mar 2017 23:49:27 +0100 |
parent | 7950:f91e7ec9654e |
parent | 7975:c64ddee9d671 |
child | 8487:91f6815de26a |
line wrap: on
line diff
--- a/core/moduleapi.lua Sun Mar 12 12:52:55 2017 +0100 +++ b/core/moduleapi.lua Thu Mar 16 23:49:27 2017 +0100 @@ -214,7 +214,7 @@ 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 @@ 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 @@ 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 @@ 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