aggregate_root 2.18.0 → 2.19.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cea5ad2176ba3e7cb7bf1b4c7b02e0b3b0fd9ed6c77b1316b3d793a8ce9f3a5b
|
|
4
|
+
data.tar.gz: 5a3d5ff57b4da8e5fe2798beb18d975b41ebeea2ffa59b6665ca8dae46a255d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dcac31c42eb2620a1cb0fabb173e1ea8f79e1b024154076cf08a341b0393bedf87852dfedd933471c50da1526e7c1bfcd2ca6928bc9d2dfa1a1f7b732bba9e5
|
|
7
|
+
data.tar.gz: bdca6260756887094170d161132593cc0ce5996954049070b04f4c9b8a7c80ae19cb0dfc22f1a0eb1c33a39e1201b7c86c6a2c3ad3734f732f91d53c46e1dfbd
|
|
@@ -6,6 +6,10 @@ module AggregateRoot
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def self.configure
|
|
9
|
+
warn <<~EOW
|
|
10
|
+
DEPRECATION WARNING: `AggregateRoot.configure` and `AggregateRoot::Configuration` are deprecated and will be removed in the next major release.
|
|
11
|
+
Use `AggregateRoot::Repository.new(event_store)` with explicit event store injection instead.
|
|
12
|
+
EOW
|
|
9
13
|
self.configuration ||= Configuration.new
|
|
10
14
|
yield(configuration)
|
|
11
15
|
end
|
|
@@ -4,6 +4,17 @@ module AggregateRoot
|
|
|
4
4
|
MissingHandler = Class.new(StandardError)
|
|
5
5
|
|
|
6
6
|
class DefaultApplyStrategy
|
|
7
|
+
DEPRECATION_MESSAGE = <<~EOW
|
|
8
|
+
Handling events via apply_* method naming convention is deprecated and will be removed in the next major release.
|
|
9
|
+
|
|
10
|
+
Use the on DSL instead:
|
|
11
|
+
|
|
12
|
+
on %s do |event|
|
|
13
|
+
# your code
|
|
14
|
+
end
|
|
15
|
+
EOW
|
|
16
|
+
private_constant :DEPRECATION_MESSAGE
|
|
17
|
+
|
|
7
18
|
def initialize(strict: true)
|
|
8
19
|
@strict = strict
|
|
9
20
|
end
|
|
@@ -20,15 +31,19 @@ module AggregateRoot
|
|
|
20
31
|
private
|
|
21
32
|
|
|
22
33
|
def handler_name(aggregate, event)
|
|
23
|
-
on_dsl_handler_name(aggregate, event.event_type) || apply_handler_name(event.event_type)
|
|
34
|
+
on_dsl_handler_name(aggregate, event.event_type) || apply_handler_name(aggregate, event.event_type)
|
|
24
35
|
end
|
|
25
36
|
|
|
26
37
|
def on_dsl_handler_name(aggregate, event_type)
|
|
27
38
|
aggregate.class.on_methods[event_type] if aggregate.class.respond_to?(:on_methods)
|
|
28
39
|
end
|
|
29
40
|
|
|
30
|
-
def apply_handler_name(event_type)
|
|
31
|
-
"apply_#{Transform.to_snake_case(event_type(event_type))}"
|
|
41
|
+
def apply_handler_name(aggregate, event_type)
|
|
42
|
+
name = "apply_#{Transform.to_snake_case(event_type(event_type))}"
|
|
43
|
+
if aggregate.respond_to?(name, true)
|
|
44
|
+
warn DEPRECATION_MESSAGE % event_type
|
|
45
|
+
end
|
|
46
|
+
name
|
|
32
47
|
end
|
|
33
48
|
|
|
34
49
|
def event_type(event_type)
|
|
@@ -8,7 +8,8 @@ module AggregateRoot
|
|
|
8
8
|
|
|
9
9
|
def load(aggregate, stream_name)
|
|
10
10
|
event_store.read.stream(stream_name).reduce { |_, ev| aggregate.apply(ev) }
|
|
11
|
-
|
|
11
|
+
event_count = aggregate.unpublished_events.size # mutant:disable
|
|
12
|
+
aggregate.version = event_count - 1
|
|
12
13
|
aggregate
|
|
13
14
|
end
|
|
14
15
|
|
|
@@ -18,7 +19,8 @@ module AggregateRoot
|
|
|
18
19
|
stream_name: stream_name,
|
|
19
20
|
expected_version: aggregate.version,
|
|
20
21
|
)
|
|
21
|
-
|
|
22
|
+
event_count = aggregate.unpublished_events.size # mutant:disable
|
|
23
|
+
aggregate.version = aggregate.version + event_count
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
def with_aggregate(aggregate, stream_name, &block)
|
|
@@ -31,6 +33,10 @@ module AggregateRoot
|
|
|
31
33
|
attr_reader :event_store
|
|
32
34
|
|
|
33
35
|
def default_event_store
|
|
36
|
+
warn <<~EOW
|
|
37
|
+
DEPRECATION WARNING: Calling `AggregateRoot::Repository.new` without an event store argument relies on `AggregateRoot::Configuration` which is deprecated and will be removed in the next major release.
|
|
38
|
+
Use `AggregateRoot::Repository.new(event_store)` with explicit event store injection instead.
|
|
39
|
+
EOW
|
|
34
40
|
AggregateRoot.configuration.default_event_store
|
|
35
41
|
end
|
|
36
42
|
end
|
|
@@ -35,15 +35,16 @@ module AggregateRoot
|
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
query.reduce { |_, ev| aggregate.apply(ev) }
|
|
38
|
-
|
|
38
|
+
event_count = aggregate.unpublished_events.size # mutant:disable
|
|
39
|
+
aggregate.version = aggregate.version + event_count
|
|
39
40
|
aggregate
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def store(aggregate, stream_name)
|
|
43
44
|
events = aggregate.unpublished_events.to_a
|
|
44
45
|
event_store.publish(events, stream_name: stream_name, expected_version: aggregate.version)
|
|
45
|
-
|
|
46
|
-
aggregate.version = aggregate.version +
|
|
46
|
+
published_count = events.size # mutant:disable
|
|
47
|
+
aggregate.version = aggregate.version + published_count
|
|
47
48
|
|
|
48
49
|
if time_for_snapshot?(aggregate.version, events.size)
|
|
49
50
|
begin
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aggregate_root
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.19.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arkency
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
18
|
+
version: 2.19.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.
|
|
25
|
+
version: 2.19.0
|
|
26
26
|
email: dev@arkency.com
|
|
27
27
|
executables: []
|
|
28
28
|
extensions: []
|
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
63
|
version: '0'
|
|
64
64
|
requirements: []
|
|
65
|
-
rubygems_version:
|
|
65
|
+
rubygems_version: 4.0.6
|
|
66
66
|
specification_version: 4
|
|
67
67
|
summary: Event sourced aggregate root implementation for RubyEventStore
|
|
68
68
|
test_files: []
|