event_sorcerer 0.0.1 → 0.0.2
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 +4 -4
- data/lib/event_sorcerer/unit_of_work.rb +13 -1
- data/lib/event_sorcerer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3a2387b8993e5a4c07e5a15d3e2f15a2a91bba3
|
4
|
+
data.tar.gz: 4f3bb03fdb88fc85b045347683b7aa9729a1df8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b35be0ea6bf136cadfacec2f8962d0b93b962c87fbee70c74447b57e90f361c76ac7633ed087ca84838ef703e4564d995adca502558da6a763dcd30bc705cd0
|
7
|
+
data.tar.gz: 8426122f4f7e433c5f8a31ab5147c376edf2fce262b1afcd2129b14a22334362d23ee1fd6abefec674925bc7fab41d7c1b2f94f770d6711ece7c80d4413c2033
|
@@ -10,9 +10,16 @@ module EventSorcerer
|
|
10
10
|
# Public: Creates a new UnitOfWork instance.
|
11
11
|
def initialize
|
12
12
|
@identity_map = {}
|
13
|
+
@meta = {}
|
13
14
|
@pending_saves = []
|
14
15
|
end
|
15
16
|
|
17
|
+
# Public: Add additional meta data to be sent along with any save reciepts
|
18
|
+
# on the message bus for the duration of the unit of work.
|
19
|
+
def add_meta_data(meta_hash)
|
20
|
+
meta.merge! meta_hash
|
21
|
+
end
|
22
|
+
|
16
23
|
# Public: Executes all pending saves within a transaction, clears the
|
17
24
|
# pending saves, and publishes the reciepts via the message bus.
|
18
25
|
#
|
@@ -26,7 +33,7 @@ module EventSorcerer
|
|
26
33
|
|
27
34
|
save_receipts.each do |reciept|
|
28
35
|
message_bus.publish_events(reciept.id, reciept.klass, reciept.events,
|
29
|
-
reciept.meta)
|
36
|
+
reciept.meta.merge(meta))
|
30
37
|
end
|
31
38
|
|
32
39
|
self
|
@@ -44,6 +51,8 @@ module EventSorcerer
|
|
44
51
|
|
45
52
|
def handle_save(save)
|
46
53
|
pending_saves << save
|
54
|
+
|
55
|
+
self
|
47
56
|
end
|
48
57
|
|
49
58
|
# Public: Stores an aggregate via it's ID into the identity map.
|
@@ -64,6 +73,9 @@ module EventSorcerer
|
|
64
73
|
# Private: Returns the identity map Hash.
|
65
74
|
attr_reader :identity_map
|
66
75
|
|
76
|
+
# Private: Returns extra metadata hash.
|
77
|
+
attr_reader :meta
|
78
|
+
|
67
79
|
# Private: Returns the pending saves Array.
|
68
80
|
attr_reader :pending_saves
|
69
81
|
end
|