nuntius 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nuntius/life_cycle.rb +12 -10
- data/lib/nuntius/state_machine.rb +6 -7
- data/lib/nuntius/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31774d0d45d8e8ee5f3f21e3baf1c6e800b77f38bf2b24e1cf632fa6b8ed7311
|
4
|
+
data.tar.gz: 5ab732ed850b97583e0a0107dea544d13b1def7136623bd93aace4e167db8392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f89d948522163e6264213aa3463c7abbddf6fd9fd0359ab622b70f334a50ed74c0a078945f2dd85532f3535fb99c329f8736fbaa256c2fdac46e59b9b5c4d990
|
7
|
+
data.tar.gz: b1a67097cccd947ed4aac0a99a3ced99dda5d70f74793d5874d6cefec6f85f2eda6572ce540b5747e21cd9564c534aaccd7791c35f50688f9dece974f2690fad
|
data/lib/nuntius/life_cycle.rb
CHANGED
@@ -7,16 +7,18 @@ module Nuntius
|
|
7
7
|
included do
|
8
8
|
raise "#{name} must be nuntiable" unless nuntiable?
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
after_create_commit do
|
11
|
+
Nuntius.event(:create, self)
|
12
|
+
Nuntius.event(:save, self)
|
13
|
+
end
|
14
|
+
|
15
|
+
after_update_commit do
|
16
|
+
Nuntius.event(:update, self)
|
17
|
+
Nuntius.event(:save, self)
|
18
|
+
end
|
19
|
+
|
20
|
+
after_destroy_commit do
|
21
|
+
Nuntius.event(:destroy, self)
|
20
22
|
end
|
21
23
|
|
22
24
|
%i[create destroy update save].each do |event_name|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nuntius
|
4
|
-
|
5
4
|
module StateMachine
|
6
5
|
extend ActiveSupport::Concern
|
7
6
|
|
@@ -9,17 +8,17 @@ module Nuntius
|
|
9
8
|
raise "#{name} must be nuntiable" unless nuntiable?
|
10
9
|
|
11
10
|
state_machine.events.map(&:name)
|
12
|
-
|
13
|
-
|
11
|
+
.reject { |event_name| messenger.method_defined?(event_name) }
|
12
|
+
.each do |event_name|
|
14
13
|
messenger.send(:define_method, event_name) { |object, options = {}| }
|
15
14
|
end
|
16
15
|
|
17
16
|
after_commit do
|
18
|
-
Thread.current[
|
17
|
+
Thread.current["___nuntius_state_machine_events"]&.each do |event|
|
19
18
|
Nuntius.event(event[:event], event[:object])
|
20
19
|
end
|
21
20
|
# After events are fired we can clear the events
|
22
|
-
Thread.current[
|
21
|
+
Thread.current["___nuntius_state_machine_events"] = []
|
23
22
|
end
|
24
23
|
|
25
24
|
state_machine do
|
@@ -32,8 +31,8 @@ module Nuntius
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def ___record__nuntius_state_machine_event(event, object)
|
35
|
-
Thread.current[
|
36
|
-
Thread.current[
|
34
|
+
Thread.current["___nuntius_state_machine_events"] ||= []
|
35
|
+
Thread.current["___nuntius_state_machine_events"] << {event: event, object: object}
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
data/lib/nuntius/version.rb
CHANGED