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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36d46202837a34ff0d400afc96a903aed10b2b46ad7d6bede57498f46f784a33
4
- data.tar.gz: 1e7cb04b9662c6e1aa5e12cbee17e2ba0f5fec1c29483b802bd1bb372da67077
3
+ metadata.gz: 31774d0d45d8e8ee5f3f21e3baf1c6e800b77f38bf2b24e1cf632fa6b8ed7311
4
+ data.tar.gz: 5ab732ed850b97583e0a0107dea544d13b1def7136623bd93aace4e167db8392
5
5
  SHA512:
6
- metadata.gz: 8da8d020db852a34e22b10ef09bae1e1b4f2d99b687ce77d834f769cae723458b0ed251fe0333a8cba9f11484c845d4dc057f292f756761b5c270293203efdc9
7
- data.tar.gz: 9548dec8eb79e8d6bffd934b695a9801c5a7692359ab83708f4c2055fc6d01c9fa92c5e0e87165a0e146340a2cbfa16ed6d8aa82c6429734950bf80339894601
6
+ metadata.gz: f89d948522163e6264213aa3463c7abbddf6fd9fd0359ab622b70f334a50ed74c0a078945f2dd85532f3535fb99c329f8736fbaa256c2fdac46e59b9b5c4d990
7
+ data.tar.gz: b1a67097cccd947ed4aac0a99a3ced99dda5d70f74793d5874d6cefec6f85f2eda6572ce540b5747e21cd9564c534aaccd7791c35f50688f9dece974f2690fad
@@ -7,16 +7,18 @@ module Nuntius
7
7
  included do
8
8
  raise "#{name} must be nuntiable" unless nuntiable?
9
9
 
10
- after_commit do
11
- if previously_persisted?
12
- Nuntius.event(:destroy, self)
13
- elsif previously_new_record?
14
- Nuntius.event(:create, self)
15
- Nuntius.event(:save, self)
16
- else
17
- Nuntius.event(:update, self)
18
- Nuntius.event(:save, self)
19
- end
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
- .reject { |event_name| messenger.method_defined?(event_name) }
13
- .each do |event_name|
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['___nuntius_state_machine_events']&.each do |event|
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['___nuntius_state_machine_events'] = []
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['___nuntius_state_machine_events'] ||= []
36
- Thread.current['___nuntius_state_machine_events'] << { event: event, object: object }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nuntius
4
- VERSION = "1.3.2"
4
+ VERSION = "1.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuntius
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt