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 +4 -4
- data/app/models/concerns/rails_simple_event_sourcing/read_only.rb +7 -3
- data/app/models/rails_simple_event_sourcing/event.rb +1 -3
- data/lib/rails_simple_event_sourcing/command_handler_registry.rb +4 -10
- data/lib/rails_simple_event_sourcing/engine.rb +0 -1
- data/lib/rails_simple_event_sourcing/version.rb +1 -1
- metadata +2 -3
- data/lib/rails_simple_event_sourcing/apply_with_returning_aggregate.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d30476e9eae518afc83f79c53c821eed02ca3029de688ec4431fa12b0b1838ac
|
|
4
|
+
data.tar.gz: 6ae993b5cc5ec4288909560b2983b24e7786fd237249bd1737e56b64b56c1323
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
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
|
+
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-
|
|
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
|