--///////////////////////////////////////////////////////////////////
--///////// ORIGINAL CODE BY TYRIR. COPYRIGHT GOES TO HIM. //////////
--///////////////////////////////////////////////////////////////////

ArendamethUtils = ArendamethUtils or {}

ArendamethUtils.patchClassMethod = function(class, methodName, createPatch)
    local metatable = __classmetatables[class]
    if not metatable then
        error("Unable to find metatable for class "..tostring(class))
    end
    local metatable__index = metatable.__index
    if not metatable__index then
        error("Unable to find __index in metatable for class "..tostring(class))
    end
    local originalMethod = metatable__index[methodName]
    metatable__index[methodName] = createPatch(originalMethod)
end