Sha256: bfde73d46d4e6c33f0072a603b9912fdb898421957fac62f75c8ec1c5c7f3808

Contents?: true

Size: 602 Bytes

Versions: 7

Compression:

Stored size: 602 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
        "#<%s:0x00%x>" % [self.class.name, object_id.abs * 2]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
avromatic-0.4.0 lib/avromatic/model/value_object.rb
avromatic-0.3.0 lib/avromatic/model/value_object.rb
avromatic-0.2.0 lib/avromatic/model/value_object.rb
avromatic-0.1.2 lib/avromatic/model/value_object.rb
avromatic-0.1.2.pre.rc0 lib/avromatic/model/value_object.rb
avromatic-0.1.1 lib/avromatic/model/value_object.rb
avromatic-0.1.0 lib/avromatic/model/value_object.rb