Sha256: c0d13030ec932891c2aecfdf6e28dca6b1fd16788755d075a3e27f2ddda6bec2

Contents?: true

Size: 653 Bytes

Versions: 2

Compression:

Stored size: 653 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('#<%<class_name>s:0x00%<identifier>x>', class_name: self.class.name, identifier: object_id.abs * 2)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avromatic-1.0.0 lib/avromatic/model/value_object.rb
avromatic-0.33.0 lib/avromatic/model/value_object.rb