You can do the same thing in a lot less code by getting the value from the class colors table instead of hard-coding in a bunch of checks and values for every class:
Lua Code:
local _, class = UnitClass("player")
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
self.bg:SetVertexColor(color.r, color.g, color.b, self.bg:GetAlpha())
This also has the advantage of supporting
custom class colors.