mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(class): use mixins for default class methods
This commit is contained in:
@@ -21,8 +21,10 @@ local function assertType(id, var, expected)
|
||||
return true
|
||||
end
|
||||
|
||||
local mixins = {}
|
||||
|
||||
---Creates a new instance of the given class.
|
||||
local function createObj(class, obj)
|
||||
function mixins.new(class, obj)
|
||||
if obj.private then
|
||||
assertType('private', obj.private, 'table')
|
||||
setmetatable(obj.private, private_mt)
|
||||
@@ -42,11 +44,9 @@ end
|
||||
function lib.class(name, super)
|
||||
assertType(1, name, 'string')
|
||||
|
||||
local class = {
|
||||
__name = name,
|
||||
new = createObj,
|
||||
}
|
||||
local class = table.clone(mixins)
|
||||
|
||||
class.__name = name
|
||||
class.__index = class
|
||||
|
||||
return super and setmetatable(class, super) or class
|
||||
|
||||
Reference in New Issue
Block a user