Module: Virtus::ValueObject

Defined in:
lib/virtus/value_object.rb

Overview

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)

Examples:

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

Defined Under Namespace

Modules: AllowedWriterMethods, ClassMethods, InstanceMethods