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
|
---@return T
|
||||||
function mixins.new(class, ...)
|
function mixins.new(class, ...)
|
||||||
local constructor = getConstructor(class)
|
local constructor = getConstructor(class)
|
||||||
|
local private = {}
|
||||||
local obj = setmetatable({
|
local obj = setmetatable({ private = private }, class)
|
||||||
private = {}
|
|
||||||
}, class)
|
|
||||||
|
|
||||||
if constructor then
|
if constructor then
|
||||||
local parent = class
|
local parent = class
|
||||||
@@ -75,8 +73,8 @@ function mixins.new(class, ...)
|
|||||||
|
|
||||||
rawset(obj, 'super', nil)
|
rawset(obj, 'super', nil)
|
||||||
|
|
||||||
if next(obj.private) then
|
if private ~= obj.private or next(obj.private) then
|
||||||
local private = table.clone(obj.private)
|
private = table.clone(obj.private)
|
||||||
|
|
||||||
table.wipe(obj.private)
|
table.wipe(obj.private)
|
||||||
setmetatable(obj.private, {
|
setmetatable(obj.private, {
|
||||||
|
|||||||
Reference in New Issue
Block a user