Skip to content

Instantly share code, notes, and snippets.

@gphg
Created September 6, 2026 17:21
Show Gist options
  • Select an option

  • Save gphg/4952a0064ddb4f2c5abf49af598d7608 to your computer and use it in GitHub Desktop.

Select an option

Save gphg/4952a0064ddb4f2c5abf49af598d7608 to your computer and use it in GitHub Desktop.
Common Middleclass mixins module for reusability.
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