Created
September 6, 2026 17:21
-
-
Save gphg/4952a0064ddb4f2c5abf49af598d7608 to your computer and use it in GitHub Desktop.
Common Middleclass mixins module for reusability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local MethodBakeMixin = {} | |
| function MethodBakeMixin:bakeMethods() | |
| local currentClass = self.class | |
| -- Walk up until there is no longer a superclass (the root class) | |
| while currentClass do | |
| for key, value in pairs(currentClass) do | |
| if type(value) == "function" and self[key] == nil then | |
| self[key] = value | |
| end | |
| end | |
| currentClass = currentClass.super | |
| end | |
| end | |
| return { | |
| MethodBakeMixin = MethodBakeMixin | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment