active_event_store 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -1
- data/lib/active_event_store/event.rb +23 -3
- data/lib/active_event_store/mapper.rb +2 -2
- data/lib/active_event_store/rspec/have_enqueued_async_subscriber_for.rb +1 -1
- data/lib/active_event_store/rspec/have_published_event.rb +1 -1
- data/lib/active_event_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e30fb94607e7da220ae329dc09190d0c39faf49394d89765602995de0bd5c9a
|
4
|
+
data.tar.gz: 5914c2c6eb4c4815e3161cfe255ae2a204106d41d60214a1989d971e92bb4549
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a1fa79f9c438b87217440a5a952b26d802813d07bd0d11eb13aa735fe5140de93b598dbf9893f44e0f931abff7c675535e24250f9402ea0f47d4ce9d817455
|
7
|
+
data.tar.gz: fd84fdaed7083159e703b420330cf2327f37e3bc862e85d32c7c14afa019a1cb4453deeda428d245ac059bafcb6b6dbbeb9a45a0fe88712ad9fdccaf3ec6bc89
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Secondly, we wanted to have a store implementation independent API that would al
|
|
17
17
|
|
18
18
|
## Installation
|
19
19
|
|
20
|
-
Add gem to your project:
|
20
|
+
Add the gem to your project:
|
21
21
|
|
22
22
|
```ruby
|
23
23
|
# Gemfile
|
@@ -143,6 +143,8 @@ Subscribers could be any callable Ruby objects that accept a single argument (ev
|
|
143
143
|
|
144
144
|
We suggest putting subscribers to the `app/subscribers` folder using the following convention: `app/subscribers/on_<event_type>/<subscriber.rb>`, e.g. `app/subscribers/on_profile_created/create_chat_user.rb`.
|
145
145
|
|
146
|
+
**NOTE:** Active Job must be loaded to use async subscribers (i.e., `require "active_job/railtie"` or `require "rails/all"` in your `config/application.rb`).
|
147
|
+
|
146
148
|
### Testing
|
147
149
|
|
148
150
|
You can test subscribers as normal Ruby objects.
|
@@ -161,6 +163,8 @@ it "is subscribed to some event" do
|
|
161
163
|
end
|
162
164
|
```
|
163
165
|
|
166
|
+
**NOTE:** You must have `rspec-rails` gem in your bundle to use `have_enqueued_async_subscriber_for` matcher.
|
167
|
+
|
164
168
|
For synchronous subscribers using `have_received` is enough:
|
165
169
|
|
166
170
|
```ruby
|
@@ -68,12 +68,32 @@ module ActiveEventStore
|
|
68
68
|
super(**{event_id: event_id, metadata: metadata, data: params}.compact)
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
# RES 0.44+
|
72
|
+
# https://github.com/RailsEventStore/rails_event_store/pull/724
|
73
|
+
if method_defined?(:event_type)
|
74
|
+
def event_type
|
75
|
+
self.class.identifier
|
76
|
+
end
|
77
|
+
else
|
78
|
+
def type
|
79
|
+
self.class.identifier
|
80
|
+
end
|
81
|
+
|
82
|
+
alias event_type type
|
73
83
|
end
|
74
84
|
|
75
85
|
def inspect
|
76
|
-
"#{self.class.name}<#{
|
86
|
+
"#{self.class.name}<#{event_type}##{message_id}>, data: #{data}, metadata: #{metadata}"
|
87
|
+
end
|
88
|
+
|
89
|
+
# Has been removed from RES: https://github.com/RailsEventStore/rails_event_store/pull/726
|
90
|
+
def to_h
|
91
|
+
{
|
92
|
+
event_id: event_id,
|
93
|
+
metadata: metadata.to_h,
|
94
|
+
data: data,
|
95
|
+
type: event_type
|
96
|
+
}
|
77
97
|
end
|
78
98
|
|
79
99
|
protected
|
@@ -24,13 +24,13 @@ module ActiveEventStore
|
|
24
24
|
# lazily add type to mapping
|
25
25
|
# NOTE: use class name instead of a class to handle code reload
|
26
26
|
# in development (to avoid accessing orphaned classes)
|
27
|
-
mapping.register(domain_event.
|
27
|
+
mapping.register(domain_event.event_type, domain_event.class.name) unless mapping.exist?(domain_event.event_type)
|
28
28
|
|
29
29
|
RubyEventStore::SerializedRecord.new(
|
30
30
|
event_id: domain_event.event_id,
|
31
31
|
metadata: serializer.dump(domain_event.metadata.to_h),
|
32
32
|
data: serializer.dump(domain_event.data),
|
33
|
-
event_type: domain_event.
|
33
|
+
event_type: domain_event.event_type
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
@@ -23,7 +23,7 @@ module ActiveEventStore
|
|
23
23
|
def matches?(actual_serialized)
|
24
24
|
actual = ActiveEventStore.event_store.deserialize(actual_serialized)
|
25
25
|
|
26
|
-
actual.
|
26
|
+
actual.event_type == event.event_type && data_matches?(actual.data)
|
27
27
|
end
|
28
28
|
|
29
29
|
def description
|
@@ -66,7 +66,7 @@ module ActiveEventStore
|
|
66
66
|
|
67
67
|
@matching_events, @unmatching_events =
|
68
68
|
in_block_events.partition do |actual_event|
|
69
|
-
(event_class.identifier == actual_event.
|
69
|
+
(event_class.identifier == actual_event.event_type) &&
|
70
70
|
(attributes.nil? || attributes_match?(actual_event))
|
71
71
|
end
|
72
72
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_event_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails_event_store
|