Commit 2f571bb0 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen
Browse files

allow passing arguments to init when creating objects with class.new

parent 59879efc
......@@ -298,8 +298,8 @@ function Rule:trules()
setfamilies(res)
tag(res, 'chain', self:chain())
local addrofrags = combinations(Zone.new({addr=self.src}):optfrags('in'),
Zone.new({addr=self.dest}):optfrags('out'))
local addrofrags = combinations(Zone.morph({addr=self.src}):optfrags('in'),
Zone.morph({addr=self.dest}):optfrags('out'))
if addrofrags then
addrofrags = ffilter(addrofrags)
......
......@@ -13,15 +13,12 @@ function class(base)
if base then setmetatable(cls, {__index = base}) end
function cls.new(...)
local inst = arg[1] and arg[1] or {}
cls.morph(inst)
return inst
end
function cls.new(...) return cls.morph({}, unpack(arg)) end
function cls:morph(...)
setmetatable(self, mt)
self:init(unpack(arg))
return self
end
return cls
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment