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)


8
9
10
# File 'lib/avromatic/model/value_object.rb', line 8

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

#hashObject



13
14
15
# File 'lib/avromatic/model/value_object.rb', line 13

def hash
  attributes.hash
end

#inspectObject



17
18
19
# File 'lib/avromatic/model/value_object.rb', line 17

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

#to_sObject



21
22
23
# File 'lib/avromatic/model/value_object.rb', line 21

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