Classification of rings with unit graphs having domination number less than four