From 5427c2472d1b6ddd57b01eaafe90a0bc4f09ffaa Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 26 Mar 2023 13:13:31 +0200 Subject: 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. --- util/roles.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/util/roles.lua b/util/roles.lua index 24444c3d..e7f22c12 100644 --- a/util/roles.lua +++ b/util/roles.lua @@ -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 -- cgit v1.2.3