Is this necessary? transitions.values should be empty if transtions is empty. Otherwise, I think this should be in the unless conditions:

unless transitions.any? && ...