Sha256: 3793069a0e6ea1a8d0a64dfc649c16cbe6a64c051bf62f61ee30cdfa01475ca3

Contents?: true

Size: 606 Bytes

Versions: 9

Compression:

Stored size: 606 Bytes

Contents

module Avromatic
  module Model

    # This module is used to override the comparisons defined by
    # Virtus::Equalizer which is pulled in by Virtus::ValueObject.
    module ValueObject
      def eql?(other)
        other.instance_of?(self.class) && attributes == other.attributes
      end
      alias_method :==, :eql?

      def hash
        attributes.hash
      end

      def inspect
        "#<#{self.class.name} #{attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')}>"
      end

      def to_s
        format('#<%s:0x00%x>', self.class.name, object_id.abs * 2)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
avromatic-0.9.0.rc1 lib/avromatic/model/value_object.rb
avromatic-0.9.0.rc0 lib/avromatic/model/value_object.rb
avromatic-0.8.0 lib/avromatic/model/value_object.rb
avromatic-0.7.1 lib/avromatic/model/value_object.rb
avromatic-0.7.0 lib/avromatic/model/value_object.rb
avromatic-0.6.2 lib/avromatic/model/value_object.rb
avromatic-0.6.1 lib/avromatic/model/value_object.rb
avromatic-0.6.0 lib/avromatic/model/value_object.rb
avromatic-0.5.0 lib/avromatic/model/value_object.rb