-
I am wondering what would be the proper way of dealing with non-string attributes, for example, numeric. I would like to have the actual object's method return the proper type. Considering this object: class Person < Ohm::Model
attribute :age
end I will always have to call So far the best idea I have is to create a shadow attribute: class Person < Ohm::Model
attribute :age_str
def age
age_str.to_i
end
def age=(val)
age_str=val
end
end is there a cleaner approach? |
Beta Was this translation helpful? Give feedback.
Answered by
soveran
Dec 17, 2022
Replies: 1 comment 5 replies
-
Maybe Ohm::DataTypes could be the way to go for that use case. |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
DannyBen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe Ohm::DataTypes could be the way to go for that use case.