Software /
code /
prosody
Changeset
12987:2cf8d98d8a28
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 26 Mar 2023 13:13:31 +0200 |
parents | 12986:895a82c5d8d4 |
children | 12988:8592770be63a |
files | util/roles.lua |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/util/roles.lua Sun Mar 26 13:07:20 2023 +0200 +++ b/util/roles.lua Sun Mar 26 13:13:31 2023 +0200 @@ -73,6 +73,19 @@ 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