Closed techthumb closed 9 years ago
value object by definition needs equality methods, it also comes with private writes so you can't change a VO instance using its public methods. It is not frozen though, something I wanted to improve in virtus 2.0. This means if you need an object that is treated as an immutable value then you should use value_object
not model
.
Virtus models could easily get equality methods by include Equalizer.new(*attribute_set.map(&:name))
if you wanted to use this functionality.
Got it. Thanks!
Hi,
Thanks for making this library public. We find it extremely useful.
Could you shed some light on the differences between
Virtus.model
andVirtus.value_object
and what context should each be used in?I've been thinking of using
Virtus.value_object
mainly for the equality matching. However, I wonder why that functionality is not already a part ofVirtus.model
.Thanks