rails_simple_event_sourcing 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bae2bfe7377ee1c5b4db35484463b437c75c8c9822791aef21867d749abd3fc
4
- data.tar.gz: b025d6954826b5a1583d0531da3e816386e407c0b26803e903b1c700ecaab2a1
3
+ metadata.gz: d30476e9eae518afc83f79c53c821eed02ca3029de688ec4431fa12b0b1838ac
4
+ data.tar.gz: 6ae993b5cc5ec4288909560b2983b24e7786fd237249bd1737e56b64b56c1323
5
5
  SHA512:
6
- metadata.gz: d3f40d21d78f8d5a978086439521814a9f3903eda901669b88cafc070ab8c01fd7664cb9e5cfefa35c401384c780bc867137e9486e3d3ee37d58ae4ffa3938f6
7
- data.tar.gz: 3aa5edd3c94f4fe350c5409371430e7e242bdfef76e472bd9f394d011b69b97b295438c3161f2d70c38e7cdb1ca42b4d1f59b335994f175cdbd76f86ebd8b0e1
6
+ metadata.gz: 1d00b4ec0df1f3a08f089e2ed307fc638cfbe92f7c7a5f6c54b48c3a02ed065e00aa8e0ceb421302ed2daaad6883281c6606caa7a45b88683cb9f9ce57fbf8c2
7
+ data.tar.gz: fa7af20a15464beaf0cc0722cf342fc8ca96b84c9fde7c581ef8b53a0eb7ce360bc5b857be870b4cc45001595743310870803f28d526ca127159be1ec86c2e2d
@@ -5,14 +5,18 @@ module RailsSimpleEventSourcing
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- attribute :write_access_enabled, :boolean, default: false
9
-
10
8
  def readonly?
11
9
  super || !write_access_enabled
12
10
  end
13
11
 
14
12
  def enable_write_access!
15
- self.write_access_enabled = true
13
+ @write_access_enabled = true
14
+ end
15
+
16
+ private
17
+
18
+ def write_access_enabled
19
+ @write_access_enabled ||= false
16
20
  end
17
21
  end
18
22
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module RailsSimpleEventSourcing
4
4
  class Event < ApplicationRecord
5
- prepend ApplyWithReturningAggregate
6
5
  include ReadOnly
7
6
  include EventAttributes
8
7
  include AggregateConfiguration
@@ -16,15 +15,14 @@ module RailsSimpleEventSourcing
16
15
 
17
16
  # Callbacks for automatic aggregate lifecycle
18
17
  before_validation :setup_event_fields, on: :create
19
- before_validation :set_version
20
18
  before_validation :apply_event_to_aggregate, on: :create, if: :aggregate_defined?
19
+ before_validation :set_version
21
20
  before_save :persist_aggregate, if: :aggregate_defined?
22
21
 
23
22
  def apply(aggregate)
24
23
  payload.each do |key, value|
25
24
  aggregate.send("#{key}=", value) if aggregate.respond_to?("#{key}=")
26
25
  end
27
- aggregate
28
26
  end
29
27
 
30
28
  private
@@ -2,20 +2,14 @@
2
2
 
3
3
  module RailsSimpleEventSourcing
4
4
  class CommandHandlerRegistry
5
+ @registry = Concurrent::Map.new
6
+
5
7
  def self.register(command_class, handler_class)
6
- registry[command_class] = handler_class
8
+ @registry[command_class] = handler_class
7
9
  end
8
10
 
9
11
  def self.handler_for(command_class)
10
- registry[command_class]
11
- end
12
-
13
- def self.registry
14
- @registry ||= {}
15
- end
16
-
17
- def self.clear
18
- @registry = {}
12
+ @registry[command_class]
19
13
  end
20
14
  end
21
15
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'aggregate_repository'
4
- require_relative 'apply_with_returning_aggregate'
5
4
  require_relative 'command_handler'
6
5
  require_relative 'command_handlers/base'
7
6
  require_relative 'commands/base'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSimpleEventSourcing
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_simple_event_sourcing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Baćkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-15 00:00:00.000000000 Z
11
+ date: 2026-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -89,7 +89,6 @@ files:
89
89
  - db/migrate/20231231133250_create_rails_simple_event_sourcing_events.rb
90
90
  - lib/rails_simple_event_sourcing.rb
91
91
  - lib/rails_simple_event_sourcing/aggregate_repository.rb
92
- - lib/rails_simple_event_sourcing/apply_with_returning_aggregate.rb
93
92
  - lib/rails_simple_event_sourcing/command_handler.rb
94
93
  - lib/rails_simple_event_sourcing/command_handler_registry.rb
95
94
  - lib/rails_simple_event_sourcing/command_handlers/base.rb
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RailsSimpleEventSourcing
4
- module ApplyWithReturningAggregate
5
- def apply(aggregate)
6
- aggregate.tap { super }
7
- end
8
- end
9
- end