diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-06-28 23:31:21 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-09-04 15:24:08 +0300 |
commit | 25ffc62a5b2c9a65e5c1689d5351adcf8cbef7e2 (patch) | |
tree | 7703761a8c13778b4aa6ef07d64628e760d6ba6f /acf/model/combination.lua | |
parent | 63942c3e11107bb1f3f5d874a2f3b694bb510f39 (diff) | |
download | aconf-25ffc62a5b2c9a65e5c1689d5351adcf8cbef7e2.tar.bz2 aconf-25ffc62a5b2c9a65e5c1689d5351adcf8cbef7e2.tar.xz |
eliminate deprecated module style
Diffstat (limited to 'acf/model/combination.lua')
-rw-r--r-- | acf/model/combination.lua | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/acf/model/combination.lua b/acf/model/combination.lua index 7228233..19f84cc 100644 --- a/acf/model/combination.lua +++ b/acf/model/combination.lua @@ -3,7 +3,7 @@ Copyright (c) 2012-2013 Kaarle Ritvanen See LICENSE file for license details --]] -module(..., package.seeall) +local M = {} local err = require('acf.error') local raise = err.raise @@ -18,30 +18,33 @@ local class = object.class local super = object.super -require 'stringy' +local stringy = require('stringy') -Range = class(String) +M.Range = class(String) -function Range:init(params) - super(self, Range):init(params) +function M.Range:init(params) + super(self, M.Range):init(params) if not self.type then self.type = fld.Integer end end -function Range:validate(context, value) +function M.Range:validate(context, value) local comps = stringy.split(value, '-') if #comps > 2 then raise(context.path, 'Invalid range') end for _, v in ipairs(comps) do to_field(self.type):_validate(context, v) end end -Union = class(String) +M.Union = class(String) -function Union:validate(context, value) - super(self, Union):validate(context, value) +function M.Union:validate(context, value) + super(self, M.Union):validate(context, value) for _, tpe in ipairs(self.types) do local field = to_field(tpe) if err.call(field.validate, field, context, value) then return end end raise(context.path, self.error or 'Invalid value') end + + +return M |