| Module | Virtus::ValueObject |
| In: |
lib/virtus/value_object.rb
|
Include this Module for Value Object semantics
The idea is that instances should be immutable and compared based on state
(rather than identity, as is typically the case)
@example
class GeoLocation
include Virtus::ValueObject
attribute :latitude, Float
attribute :longitude, Float
end
location = GeoLocation.new(:latitude => 10, :longitude => 100)
same_location = GeoLocation.new(:latitude => 10, :longitude => 100)
location == same_location #=> true
hash = { location => :foo }
hash[same_location] #=> :foo