active_event_store 0.1.0 → 0.2.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: 79a390bc7f50283a2ed74f34d62ae845dfa5208a19a2a174238a5ebf4a684203
4
- data.tar.gz: cfd5584f0a8c56a645fdb58fb1dfe6b35252d1c23481898974a6c333233d59a1
3
+ metadata.gz: 5e30fb94607e7da220ae329dc09190d0c39faf49394d89765602995de0bd5c9a
4
+ data.tar.gz: 5914c2c6eb4c4815e3161cfe255ae2a204106d41d60214a1989d971e92bb4549
5
5
  SHA512:
6
- metadata.gz: 91d3ecb6b2635ff0e895176e687d3fa3820d519b3d50cbba6d3d4ec9a79c632c527fd17817317d9eddf15d3c6fdff6a581f729bdcc1df55231e9250bb7332c74
7
- data.tar.gz: ce974d79cd1989cfdd86e1ecfdfbf408b1facae1b9ab0be50c72f644f9abb32a0ce0c8a024752b3f2450c921d1f3c0ec5b0a8bc31c311ff814aa0cbd8dba89df
6
+ metadata.gz: 40a1fa79f9c438b87217440a5a952b26d802813d07bd0d11eb13aa735fe5140de93b598dbf9893f44e0f931abff7c675535e24250f9402ea0f47d4ce9d817455
7
+ data.tar.gz: fd84fdaed7083159e703b420330cf2327f37e3bc862e85d32c7c14afa019a1cb4453deeda428d245ac059bafcb6b6dbbeb9a45a0fe88712ad9fdccaf3ec6bc89
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.2.0 (2020-05-11)
6
+
7
+ - Update Event API to support both RES 1.0 and 0.42+. ([@palkan][])
8
+
5
9
  ## 0.1.0 (2020-04-22)
6
10
 
7
11
  - Open source Active Event Store. ([@palkan][])
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
- def type
72
- self.class.identifier
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}<#{type}##{message_id}>, data: #{data}, metadata: #{metadata}"
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.type, domain_event.class.name) unless mapping.exist?(domain_event.type)
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.type
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.type == event.type && data_matches?(actual.data)
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.type) &&
69
+ (event_class.identifier == actual_event.event_type) &&
70
70
  (attributes.nil? || attributes_match?(actual_event))
71
71
  end
72
72
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveEventStore # :nodoc:
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
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.1.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-04-22 00:00:00.000000000 Z
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