aggregate_root 2.1.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aggregate_root/default_apply_strategy.rb +1 -1
- data/lib/aggregate_root/instrumented_repository.rb +19 -9
- data/lib/aggregate_root/repository.rb +5 -3
- data/lib/aggregate_root/transform.rb +1 -4
- data/lib/aggregate_root/version.rb +1 -1
- data/lib/aggregate_root.rb +10 -11
- metadata +7 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30ff98d2282add92ff95eca80c76a3b12f119bb0c4659bb9093f71500290bf49
|
4
|
+
data.tar.gz: 379cf4fdb8b8850fd3b0307406bc0e67046d7ec34ded9a9d86d208bdff400564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51321bc327a382249bb120094df57d864020c358f95d7350c86ed13fa3c8faf85ca7f92cb70cca346cebe5de88d2a5e6cd6cccbec38371b044fc655e131e2521
|
7
|
+
data.tar.gz: d49549c5b59eed7de2e5312af1ccc30707a55e15a799d3f30c67acc748c5690f61301e18faac5c8421ca34521bbb7bf3eeff06d99ee22e30de68d9f9426f95d6
|
@@ -8,21 +8,19 @@ module AggregateRoot
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def load(aggregate, stream_name)
|
11
|
-
instrumentation.instrument("load.repository.aggregate_root",
|
12
|
-
aggregate: aggregate,
|
13
|
-
stream: stream_name) do
|
11
|
+
instrumentation.instrument("load.repository.aggregate_root", aggregate: aggregate, stream: stream_name) do
|
14
12
|
repository.load(aggregate, stream_name)
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
16
|
def store(aggregate, stream_name)
|
19
|
-
instrumentation.instrument(
|
20
|
-
|
21
|
-
|
17
|
+
instrumentation.instrument(
|
18
|
+
"store.repository.aggregate_root",
|
19
|
+
aggregate: aggregate,
|
20
|
+
version: aggregate.version,
|
22
21
|
stored_events: aggregate.unpublished_events.to_a,
|
23
|
-
stream:
|
24
|
-
|
25
|
-
end
|
22
|
+
stream: stream_name
|
23
|
+
) { repository.store(aggregate, stream_name) }
|
26
24
|
end
|
27
25
|
|
28
26
|
def with_aggregate(aggregate, stream_name, &block)
|
@@ -30,6 +28,18 @@ module AggregateRoot
|
|
30
28
|
store(aggregate, stream_name)
|
31
29
|
end
|
32
30
|
|
31
|
+
def method_missing(method_name, *arguments, **keyword_arguments, &block)
|
32
|
+
if respond_to?(method_name)
|
33
|
+
repository.public_send(method_name, *arguments, **keyword_arguments, &block)
|
34
|
+
else
|
35
|
+
super
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def respond_to_missing?(method_name, _include_private)
|
40
|
+
repository.respond_to?(method_name)
|
41
|
+
end
|
42
|
+
|
33
43
|
private
|
34
44
|
|
35
45
|
attr_reader :instrumentation, :repository
|
@@ -13,9 +13,11 @@ module AggregateRoot
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def store(aggregate, stream_name)
|
16
|
-
event_store.publish(
|
17
|
-
|
18
|
-
|
16
|
+
event_store.publish(
|
17
|
+
aggregate.unpublished_events.to_a,
|
18
|
+
stream_name: stream_name,
|
19
|
+
expected_version: aggregate.version
|
20
|
+
)
|
19
21
|
aggregate.version = aggregate.version + aggregate.unpublished_events.count
|
20
22
|
end
|
21
23
|
|
@@ -3,10 +3,7 @@
|
|
3
3
|
module AggregateRoot
|
4
4
|
class Transform
|
5
5
|
def self.to_snake_case(name)
|
6
|
-
name
|
7
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
8
|
-
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
9
|
-
.downcase
|
6
|
+
name.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
|
10
7
|
end
|
11
8
|
end
|
12
9
|
end
|
data/lib/aggregate_root.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require 'ruby2_keywords'
|
3
|
+
require_relative "aggregate_root/version"
|
4
|
+
require_relative "aggregate_root/configuration"
|
5
|
+
require_relative "aggregate_root/transform"
|
6
|
+
require_relative "aggregate_root/default_apply_strategy"
|
7
|
+
require_relative "aggregate_root/repository"
|
8
|
+
require_relative "aggregate_root/instrumented_repository"
|
10
9
|
|
11
10
|
module AggregateRoot
|
12
11
|
module OnDSL
|
@@ -32,7 +31,7 @@ module AggregateRoot
|
|
32
31
|
end
|
33
32
|
|
34
33
|
module Constructor
|
35
|
-
|
34
|
+
def new(*, **)
|
36
35
|
super.tap do |instance|
|
37
36
|
instance.instance_variable_set(:@version, -1)
|
38
37
|
instance.instance_variable_set(:@unpublished_events, [])
|
@@ -65,8 +64,8 @@ module AggregateRoot
|
|
65
64
|
def self.with_default_apply_strategy
|
66
65
|
Module.new do
|
67
66
|
def self.included(host_class)
|
68
|
-
host_class.extend
|
69
|
-
host_class.include AggregateRoot.with_strategy(->{ DefaultApplyStrategy.new })
|
67
|
+
host_class.extend OnDSL
|
68
|
+
host_class.include AggregateRoot.with_strategy(-> { DefaultApplyStrategy.new })
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
@@ -74,7 +73,7 @@ module AggregateRoot
|
|
74
73
|
def self.with_strategy(strategy)
|
75
74
|
Module.new do
|
76
75
|
def self.included(host_class)
|
77
|
-
host_class.extend
|
76
|
+
host_class.extend Constructor
|
78
77
|
host_class.include AggregateMethods
|
79
78
|
end
|
80
79
|
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aggregate_root
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: ruby2_keywords
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: ruby_event_store
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - '='
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
19
|
+
version: 2.4.0
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - '='
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
26
|
+
version: 2.4.0
|
41
27
|
description:
|
42
28
|
email: dev@arkency.com
|
43
29
|
executables: []
|
@@ -61,6 +47,7 @@ metadata:
|
|
61
47
|
changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
|
62
48
|
source_code_uri: https://github.com/RailsEventStore/rails_event_store
|
63
49
|
bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
|
50
|
+
rubygems_mfa_required: 'true'
|
64
51
|
post_install_message:
|
65
52
|
rdoc_options: []
|
66
53
|
require_paths:
|
@@ -69,14 +56,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
56
|
requirements:
|
70
57
|
- - ">="
|
71
58
|
- !ruby/object:Gem::Version
|
72
|
-
version: '2.
|
59
|
+
version: '2.7'
|
73
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
61
|
requirements:
|
75
62
|
- - ">="
|
76
63
|
- !ruby/object:Gem::Version
|
77
64
|
version: '0'
|
78
65
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.3.7
|
80
67
|
signing_key:
|
81
68
|
specification_version: 4
|
82
69
|
summary: Event sourced aggregate root implementation for RubyEventStore
|