aggregate_root 0.40.1 → 0.41.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Makefile +1 -1
- data/aggregate_root.gemspec +5 -4
- data/lib/aggregate_root.rb +4 -2
- data/lib/aggregate_root/configuration.rb +2 -0
- data/lib/aggregate_root/default_apply_strategy.rb +2 -1
- data/lib/aggregate_root/instrumented_repository.rb +9 -6
- data/lib/aggregate_root/repository.rb +7 -4
- data/lib/aggregate_root/transform.rb +2 -0
- data/lib/aggregate_root/version.rb +3 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f5d9823c1ad8df4c57868b879f08887b51bbfb939eb80a037df6a973e2491b
|
4
|
+
data.tar.gz: 942f39b742b4e582e98f726c6b0891077ed424c8dfd40975142da153e17c96cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c9f40ad42533535e1df1bcaeef18a9439d524ba93f3b191f59249d121ec749954a5ce02ff8a51b56746abf8701d48865d5c5316e088cb9ca43936d817098c27
|
7
|
+
data.tar.gz: 639dfade2ee8da94eb4fb5aef63b377c12a9b48a2a11cba62fa6fec65c7b9f4759e6c8a4cbcd68a60ecc8ea0c625567bf6d8444adaaa40cde7cb23d0d3e81bda
|
data/Gemfile
CHANGED
data/Makefile
CHANGED
data/aggregate_root.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'aggregate_root/version'
|
@@ -13,9 +14,9 @@ Gem::Specification.new do |spec|
|
|
13
14
|
spec.summary = %q{Event sourced (with Rails Event Store) aggregate root implementation}
|
14
15
|
spec.description = %q{Event sourced (with Rails Event Store) aggregate root implementation}
|
15
16
|
spec.homepage = 'https://railseventstore.org'
|
16
|
-
spec.metadata
|
17
|
-
"homepage_uri"
|
18
|
-
"changelog_uri"
|
17
|
+
spec.metadata = {
|
18
|
+
"homepage_uri" => "https://railseventstore.org/",
|
19
|
+
"changelog_uri" => "https://github.com/RailsEventStore/rails_event_store/releases",
|
19
20
|
"source_code_uri" => "https://github.com/RailsEventStore/rails_event_store",
|
20
21
|
"bug_tracker_uri" => "https://github.com/RailsEventStore/rails_event_store/issues",
|
21
22
|
}
|
@@ -25,5 +26,5 @@ Gem::Specification.new do |spec|
|
|
25
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
27
|
spec.require_paths = ['lib']
|
27
28
|
|
28
|
-
spec.add_dependency 'ruby_event_store', '= 0.
|
29
|
+
spec.add_dependency 'ruby_event_store', '= 0.41.0'
|
29
30
|
end
|
data/lib/aggregate_root.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'aggregate_root/version'
|
2
4
|
require 'aggregate_root/configuration'
|
3
5
|
require 'aggregate_root/transform'
|
@@ -5,7 +7,6 @@ require 'aggregate_root/default_apply_strategy'
|
|
5
7
|
require 'aggregate_root/repository'
|
6
8
|
require 'aggregate_root/instrumented_repository'
|
7
9
|
|
8
|
-
|
9
10
|
module AggregateRoot
|
10
11
|
module OnDSL
|
11
12
|
ANONYMOUS_CLASS = "#<Class:".freeze
|
@@ -14,6 +15,7 @@ module AggregateRoot
|
|
14
15
|
event_klasses.each do |event_klass|
|
15
16
|
name = event_klass.to_s
|
16
17
|
raise(ArgumentError, "Anonymous class is missing name") if name.start_with? ANONYMOUS_CLASS
|
18
|
+
|
17
19
|
handler_name = "on_#{name}"
|
18
20
|
define_method(handler_name, &block)
|
19
21
|
@on_methods ||= {}
|
@@ -63,7 +65,7 @@ module AggregateRoot
|
|
63
65
|
Module.new do
|
64
66
|
def self.included(host_class)
|
65
67
|
host_class.extend OnDSL
|
66
|
-
host_class.include AggregateRoot.with_strategy(->{ DefaultApplyStrategy.new })
|
68
|
+
host_class.include AggregateRoot.with_strategy(-> { DefaultApplyStrategy.new })
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AggregateRoot
|
2
4
|
class InstrumentedRepository
|
3
5
|
def initialize(repository, instrumentation)
|
@@ -7,18 +9,18 @@ module AggregateRoot
|
|
7
9
|
|
8
10
|
def load(aggregate, stream_name)
|
9
11
|
instrumentation.instrument("load.repository.aggregate_root",
|
10
|
-
|
11
|
-
|
12
|
+
aggregate: aggregate,
|
13
|
+
stream: stream_name) do
|
12
14
|
repository.load(aggregate, stream_name)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
18
|
def store(aggregate, stream_name)
|
17
19
|
instrumentation.instrument("store.repository.aggregate_root",
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
aggregate: aggregate,
|
21
|
+
version: aggregate.version,
|
22
|
+
stored_events: aggregate.unpublished_events.to_a,
|
23
|
+
stream: stream_name) do
|
22
24
|
repository.store(aggregate, stream_name)
|
23
25
|
end
|
24
26
|
end
|
@@ -29,6 +31,7 @@ module AggregateRoot
|
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
34
|
+
|
32
35
|
attr_reader :instrumentation, :repository
|
33
36
|
end
|
34
37
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AggregateRoot
|
2
4
|
class Repository
|
3
5
|
def initialize(event_store = default_event_store)
|
@@ -5,15 +7,15 @@ module AggregateRoot
|
|
5
7
|
end
|
6
8
|
|
7
9
|
def load(aggregate, stream_name)
|
8
|
-
event_store.read.stream(stream_name).reduce {|_, ev| aggregate.apply(ev) }
|
10
|
+
event_store.read.stream(stream_name).reduce { |_, ev| aggregate.apply(ev) }
|
9
11
|
aggregate.version = aggregate.unpublished_events.count - 1
|
10
12
|
aggregate
|
11
13
|
end
|
12
14
|
|
13
15
|
def store(aggregate, stream_name)
|
14
16
|
event_store.publish(aggregate.unpublished_events.to_a,
|
15
|
-
|
16
|
-
|
17
|
+
stream_name: stream_name,
|
18
|
+
expected_version: aggregate.version)
|
17
19
|
aggregate.version = aggregate.version + aggregate.unpublished_events.count
|
18
20
|
end
|
19
21
|
|
@@ -23,10 +25,11 @@ module AggregateRoot
|
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
28
|
+
|
26
29
|
attr_reader :event_store
|
27
30
|
|
28
31
|
def default_event_store
|
29
32
|
AggregateRoot.configuration.default_event_store
|
30
33
|
end
|
31
34
|
end
|
32
|
-
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aggregate_root
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.41.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby_event_store
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.41.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.41.0
|
27
27
|
description: Event sourced (with Rails Event Store) aggregate root implementation
|
28
28
|
email:
|
29
29
|
- dev@arkency.com
|
@@ -66,7 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.7.6.2
|
70
71
|
signing_key:
|
71
72
|
specification_version: 4
|
72
73
|
summary: Event sourced (with Rails Event Store) aggregate root implementation
|