4
4
--- Copyright (c) 2014, rxi
5
5
--- @brief ]]
6
6
7
- --- @class Object
7
+ --- @class PlenaryClass
8
+ --- @overload fun ( ... ): PlenaryClass
8
9
local Object = {}
9
10
Object .__index = Object
10
11
11
12
--- Does nothing.
12
13
--- You have to implement this yourself for extra functionality when initializing
13
- --- @param self Object
14
+ --- @type fun ( self : PlenaryClass , ... )
14
15
function Object :new () end
15
16
16
17
--- Create a new class/object by extending the base Object class.
17
18
--- The extended object will have a field called `super` that will access the super class.
18
- --- @param self Object
19
- --- @return Object
19
+ --- @return PlenaryClass
20
20
function Object :extend ()
21
21
local cls = {}
22
22
for k , v in pairs (self ) do
@@ -31,8 +31,7 @@ function Object:extend()
31
31
end
32
32
33
33
--- Implement a mixin onto this Object.
34
- --- @param self Object
35
- --- @param nil ...
34
+ --- @param ... any
36
35
function Object :implement (...)
37
36
for _ , cls in pairs { ... } do
38
37
for k , v in pairs (cls ) do
45
44
46
45
--- Checks if the object is an instance
47
46
--- This will start with the lowest class and loop over all the superclasses.
48
- --- @param self Object
49
- --- @param T Object
47
+ --- @param T PlenaryClass
50
48
--- @return boolean
51
49
function Object :is (T )
52
50
local mt = getmetatable (self )
61
59
62
60
--- The default tostring implementation for an object.
63
61
--- You can override this to provide a different tostring.
64
- --- @param self Object
65
62
--- @return string
66
63
function Object :__tostring ()
67
64
return " Object"
68
65
end
69
66
70
67
--- You can call the class the initialize it without using `Object:new`.
71
- --- @param self Object
72
- --- @param nil ...
73
- --- @return Object
68
+ --- @param ... any
69
+ --- @return PlenaryClass
74
70
function Object :__call (...)
75
71
local obj = setmetatable ({}, self )
76
72
obj :new (... )
0 commit comments