diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-03-22 11:28:29 +0000 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2012-03-22 11:28:29 +0000 |
commit | 2f571bb0e760d9fafe9f2aa958e9751703c89084 (patch) | |
tree | 49431d88411457776127e1c6ae28360b483c253a | |
parent | 59879efcdfdacc394ba900be2cf48c3a155af9f3 (diff) | |
download | awall-2f571bb0e760d9fafe9f2aa958e9751703c89084.tar.bz2 awall-2f571bb0e760d9fafe9f2aa958e9751703c89084.tar.xz |
allow passing arguments to init when creating objects with class.new
-rw-r--r-- | awall/model.lua | 4 | ||||
-rw-r--r-- | awall/object.lua | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/awall/model.lua b/awall/model.lua index d0b6914..bc9bd28 100644 --- a/awall/model.lua +++ b/awall/model.lua @@ -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) diff --git a/awall/object.lua b/awall/object.lua index 23ee081..a49e96c 100644 --- a/awall/object.lua +++ b/awall/object.lua @@ -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 |