blob: 092f3323803a894ed1870db267c8e7f38cd492a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
local class = require'r.class'
local BasePylon = require 'pylon'
local Thing = require 'thing'
local Message = class()
-- since this is the beating heart of wilson, it pays to do some validation
function Message.make(cls, self)
setmetatable(self,cls)
for k,v in pairs{
pylon=BasePylon,
channel=Thing,
author=Thing,
} do assert(class.is(self[k],v), 'field '..k..' missing or wrong') end
assert(type(self.body)=='string','field body missing or wrong')
assert(self.pylon == self.channel.pylon and self.pylon == self.author.pylon,
"inconsistent pylons!")
return self end
return Message
|