mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.roles: Implement a serialization preparation metamethod
Should be able to roundtrip trough serialization. Also nice for debug and logging purposes where you might want more details than what the __tostring method provides.
This commit is contained in:
parent
196117c3f2
commit
5427c2472d
1 changed files with 13 additions and 0 deletions
|
@ -73,6 +73,19 @@ local function new(base_config, overrides)
|
|||
return setmetatable(new_role, role_mt);
|
||||
end
|
||||
|
||||
function role_mt:__freeze()
|
||||
local t = {
|
||||
id = self.id;
|
||||
name = self.name;
|
||||
description = self.description;
|
||||
default = self.default;
|
||||
priority = self.priority;
|
||||
inherits = self.inherits;
|
||||
permissions = self[permissions_key];
|
||||
};
|
||||
return t;
|
||||
end
|
||||
|
||||
function role_methods:clone(overrides)
|
||||
return new(self, overrides);
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue