Module: Avromatic::Model::ValueObject

Defined in:
lib/avromatic/model/value_object.rb

Overview

This module is used to override the comparisons defined by Virtus::Equalizer which is pulled in by Virtus::ValueObject.

Instance Method Summary collapse

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


6
7
8
# File 'lib/avromatic/model/value_object.rb', line 6

def eql?(other)
  other.instance_of?(self.class) && attributes == other.attributes
end

#hashObject



11
12
13
# File 'lib/avromatic/model/value_object.rb', line 11

def hash
  attributes.hash
end

#inspectObject



15
16
17
# File 'lib/avromatic/model/value_object.rb', line 15

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

#to_sObject



19
20
21
# File 'lib/avromatic/model/value_object.rb', line 19

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