Class: RubyEventStore::Transformations::IdentityMap
- Inherits:
-
Object
- Object
- RubyEventStore::Transformations::IdentityMap
- Defined in:
- lib/ruby_event_store/transformations/identity_map.rb
Instance Method Summary collapse
- #dump(domain_event) ⇒ Object
-
#initialize ⇒ IdentityMap
constructor
A new instance of IdentityMap.
- #load(record) ⇒ Object
Constructor Details
#initialize ⇒ IdentityMap
Returns a new instance of IdentityMap.
4 5 6 |
# File 'lib/ruby_event_store/transformations/identity_map.rb', line 4 def initialize @identity_map = {} end |
Instance Method Details
#dump(domain_event) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_event_store/transformations/identity_map.rb', line 8 def dump(domain_event) @identity_map[domain_event.event_id] = domain_event = domain_event..to_h = .delete(:timestamp) valid_at = .delete(:valid_at) Record.new( event_id: domain_event.event_id, metadata: , data: domain_event.data, event_type: domain_event.event_type, timestamp: , valid_at: valid_at, ) end |
#load(record) ⇒ Object
24 25 26 |
# File 'lib/ruby_event_store/transformations/identity_map.rb', line 24 def load(record) @identity_map.fetch(record.event_id) end |