mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(class): allow private to be redefined
Allows self.private to defined as a new table, allowing it to remain empty without being removed after instantiation. Resolves #696.
This commit is contained in:
@@ -55,10 +55,8 @@ local function void() return '' end
|
||||
---@return T
|
||||
function mixins.new(class, ...)
|
||||
local constructor = getConstructor(class)
|
||||
|
||||
local obj = setmetatable({
|
||||
private = {}
|
||||
}, class)
|
||||
local private = {}
|
||||
local obj = setmetatable({ private = private }, class)
|
||||
|
||||
if constructor then
|
||||
local parent = class
|
||||
@@ -75,8 +73,8 @@ function mixins.new(class, ...)
|
||||
|
||||
rawset(obj, 'super', nil)
|
||||
|
||||
if next(obj.private) then
|
||||
local private = table.clone(obj.private)
|
||||
if private ~= obj.private or next(obj.private) then
|
||||
private = table.clone(obj.private)
|
||||
|
||||
table.wipe(obj.private)
|
||||
setmetatable(obj.private, {
|
||||
|
||||
Reference in New Issue
Block a user