I have an array of active record objects. All objects have an attribute result and the value of result can be either 'failed' or 'passed'.
My goal is to find out if all result attributes are identical. If not then I will have to return mixed but if they are then I return the value of the attributes.
I currently have this code:
if tests.map(&:result).uniq.count != 1
'mixed'
else
tests.first.result
end
But that first line is quite ugly. I'm sure there is a better way to find out if all results are identical or not but I can't think of any.
tests = []returns'mixed'? \$\endgroup\$