Class: RubyEventStore::SerializedRecord
- Inherits:
-
Object
- Object
- RubyEventStore::SerializedRecord
- Defined in:
- lib/ruby_event_store/serialized_record.rb
Constant Summary collapse
- StringsRequired =
Class.new(StandardError)
- BIG_VALUE =
0b110011100100000010010010110011101011110101010101001100111110011
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#event_id ⇒ Object
readonly
Returns the value of attribute event_id.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(event_id:, data:, metadata:, event_type:) ⇒ SerializedRecord
constructor
A new instance of SerializedRecord.
- #to_h ⇒ Object
Constructor Details
#initialize(event_id:, data:, metadata:, event_type:) ⇒ SerializedRecord
Returns a new instance of SerializedRecord.
4 5 6 7 8 9 10 11 |
# File 'lib/ruby_event_store/serialized_record.rb', line 4 def initialize(event_id:, data:, metadata:, event_type:) raise StringsRequired unless [event_id, data, , event_type].all? { |v| v.instance_of?(String) } @event_id = event_id @data = data = @event_type = event_type freeze end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/ruby_event_store/serialized_record.rb', line 13 def data @data end |
#event_id ⇒ Object (readonly)
Returns the value of attribute event_id.
13 14 15 |
# File 'lib/ruby_event_store/serialized_record.rb', line 13 def event_id @event_id end |
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
13 14 15 |
# File 'lib/ruby_event_store/serialized_record.rb', line 13 def event_type @event_type end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
13 14 15 |
# File 'lib/ruby_event_store/serialized_record.rb', line 13 def end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
26 27 28 29 30 31 32 |
# File 'lib/ruby_event_store/serialized_record.rb', line 26 def ==(other) other.instance_of?(self.class) && other.event_id.eql?(event_id) && other.data.eql?(data) && other..eql?() && other.event_type.eql?(event_type) end |
#hash ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby_event_store/serialized_record.rb', line 16 def hash [ self.class, event_id, data, , event_type, ].hash ^ BIG_VALUE end |
#to_h ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/ruby_event_store/serialized_record.rb', line 34 def to_h { event_id: event_id, data: data, metadata: , event_type: event_type, } end |