44--- Copyright (c) 2014, rxi
55--- @brief ]]
66
7- --- @class Object
7+ --- @class PlenaryClass
8+ --- @overload fun ( ... ): PlenaryClass
89local Object = {}
910Object .__index = Object
1011
1112--- Does nothing.
1213--- You have to implement this yourself for extra functionality when initializing
13- --- @param self Object
14+ --- @type fun ( self : PlenaryClass , ... )
1415function Object :new () end
1516
1617--- Create a new class/object by extending the base Object class.
1718--- 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
2020function Object :extend ()
2121 local cls = {}
2222 for k , v in pairs (self ) do
@@ -31,8 +31,7 @@ function Object:extend()
3131end
3232
3333--- Implement a mixin onto this Object.
34- --- @param self Object
35- --- @param nil ...
34+ --- @param ... any
3635function Object :implement (...)
3736 for _ , cls in pairs { ... } do
3837 for k , v in pairs (cls ) do
4544
4645--- Checks if the object is an instance
4746--- 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
5048--- @return boolean
5149function Object :is (T )
5250 local mt = getmetatable (self )
6159
6260--- The default tostring implementation for an object.
6361--- You can override this to provide a different tostring.
64- --- @param self Object
6562--- @return string
6663function Object :__tostring ()
6764 return " Object"
6865end
6966
7067--- 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
7470function Object :__call (...)
7571 local obj = setmetatable ({}, self )
7672 obj :new (... )
0 commit comments