nuntius 1.3.1 → 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: e22c05a90ed9f7b363331c76056b422d2f882e3b142c049fd40df4f1b785d356
4
- data.tar.gz: de086dc62c3df2e6e72f810bb7643f77714bb64e282e21b001d128c2b4558d5e
3
+ metadata.gz: 31774d0d45d8e8ee5f3f21e3baf1c6e800b77f38bf2b24e1cf632fa6b8ed7311
4
+ data.tar.gz: 5ab732ed850b97583e0a0107dea544d13b1def7136623bd93aace4e167db8392
5
5
  SHA512:
6
- metadata.gz: a62bd99e311602b4201548da92b3f721275534a9982e5b5fa76d9a2650b269a928d7ab628bb06bc658d0c781106ffd92ff94345fa711f0391c62987a5a5d153a
7
- data.tar.gz: 0d547a914d5669b4016733d7da974b6deb6dd9c19ecd6f6381b75e75e0aee257dfd09fc68e61b63b4611a748bcd459e34917cf0be34020457ce2edd83bc2b0c2
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.1"
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.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt