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/net.lua | |
parent | 63942c3e11107bb1f3f5d874a2f3b694bb510f39 (diff) | |
download | aconf-25ffc62a5b2c9a65e5c1689d5351adcf8cbef7e2.tar.bz2 aconf-25ffc62a5b2c9a65e5c1689d5351adcf8cbef7e2.tar.xz |
eliminate deprecated module style
Diffstat (limited to 'acf/model/net.lua')
-rw-r--r-- | acf/model/net.lua | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/acf/model/net.lua b/acf/model/net.lua index dc63e75..e5c1836 100644 --- a/acf/model/net.lua +++ b/acf/model/net.lua @@ -3,7 +3,7 @@ Copyright (c) 2012-2013 Kaarle Ritvanen See LICENSE file for license details --]] -module(..., package.seeall) +local M = {} local raise = require('acf.error').raise local Union = require('acf.model.combination').Union @@ -18,13 +18,13 @@ local super = object.super local update = require('acf.util').update -require 'stringy' +local stringy = require('stringy') -IPv4Address = class(String) +M.IPv4Address = class(String) -function IPv4Address:validate(context, value) - super(self, IPv4Address):validate(context, value) +function M.IPv4Address:validate(context, value) + super(self, M.IPv4Address):validate(context, value) local function test(...) if #{...} ~= 4 then return true end for _, octet in ipairs{...} do @@ -37,10 +37,10 @@ function IPv4Address:validate(context, value) end -IPv6Address = class(String) +M.IPv6Address = class(String) -function IPv6Address:validate(context, value) - super(self, IPv6Address):validate(context, value) +function M.IPv6Address:validate(context, value) + super(self, M.IPv6Address):validate(context, value) local function invalid() raise(context.path, 'Invalid IPv6 address') end @@ -73,20 +73,24 @@ function IPv6Address:validate(context, value) end -IPAddress = class(Union) +M.IPAddress = class(Union) -function IPAddress:init(params) - super(self, IPAddress):init( +function M.IPAddress:init(params) + super(self, M.IPAddress):init( update( - params, {types={IPv4Address, IPv6Address}, error='Invalid IP address'} + params, + {types={M.IPv4Address, M.IPv6Address}, error='Invalid IP address'} ) ) end -Port = class(fld.Integer) +M.Port = class(fld.Integer) -function Port:validate(context, value) - super(self, Port):validate(context, value) +function M.Port:validate(context, value) + super(self, M.Port):validate(context, value) if value < 0 or value > 65535 then raise(context.path, 'Invalid port') end end + + +return M |