I have a Video
model with a property called aspect_ratio
that is an enum
:
ASPECT_RATIOS = [:four_three, :sixteen_nine]
enum aspect_ratio: ASPECT_RATIOS
The property is stored as an integer.
When I access this property, I get a string representation of the enumerated symbol
video.aspect_ratio # four_three
video.aspect_ratio.class # String
However when I iterate over the model's properties using video.attributes.each_pair
the value of aspect_ratio
is an integer. I need to iterate over attributes in such a way that if the attribute is an enum I get the string value, not its integer value.
The following also return its integer value:
video.read_attribute(:aspect_ratio)
video[:aspect_ratio]
Is there another way to iterate to ensure I get the string value of the enum?