sequel-state-machine 1.0.0 → 1.0.1

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: 75e3b94c74a1a1c835374f9e6be8d51c84b62d24cc7fd205f00ee325e1dde15a
4
- data.tar.gz: 44fcd2ffd47a5ade52a4c9eda0f6bc86f8b5991f8d9e7cbf7cf9fe0194ba8aa1
3
+ metadata.gz: 1eb11cc183e1cfcfc7917f505b02b0f801888492fcf73ac6538e5915972cc799
4
+ data.tar.gz: 355f305b70481b88cd306aed45e4bd6ec8b8706ecd921f17fb18e872e85ea36c
5
5
  SHA512:
6
- metadata.gz: 38a3c446b7b00f3a80b1257a37a0705712bc93e397963378709b0bc289aa8e85d372d869e53c94ae439a1ab83c3b507cb07af0ebe5049abd89e9c8c76088e382
7
- data.tar.gz: 7a7da89ec5c83001e726c90dd83e52b973754528a71d9a360c78ea2a1bb9a09ae9dc47c965e5962d156c38fd85a052c0ac56d7f29607e8689564f8cd11b0aec0
6
+ metadata.gz: e26ed08fbc26ece33859b8b68b1ce95573060437054ed1c2e7f69e751c80c5a9d0e29c0ad81ab2c2ec1985c54bcc0fd8327d940329868e7c0937b1baa0f4f64f
7
+ data.tar.gz: 32164513eb750973c18e54b73defeb9aa3e45635653725733ff4c1f0f1665693a2eecb569b2d749d04010c586c86bf44f20b8558e6c44f5df85ce9c73b47c8de
@@ -52,13 +52,22 @@ module Sequel
52
52
 
53
53
  module InstanceMethods
54
54
  def failed?
55
- colmap = self.state_machine_column_mappings
56
- return colmap[:from_state] == colmap[:to_state]
55
+ from_state = self._get_mapped_column_value(:from_state)
56
+ to_state = self._get_mapped_column_value(:to_state)
57
+ return from_state == to_state
57
58
  end
58
59
 
59
60
  def succeeded?
60
- colmap = self.state_machine_column_mappings
61
- return colmap[:from_state] != colmap[:to_state]
61
+ return !self.failed?
62
+ end
63
+
64
+ def full_message
65
+ msg = self._get_mapped_column_value(:messages)
66
+ return self.class.state_machine_messages_supports_array ? msg.join(", ") : msg
67
+ end
68
+
69
+ def _get_mapped_column_value(col)
70
+ return self[self.class.state_machine_column_mappings[col]]
62
71
  end
63
72
  end
64
73
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module StateMachines
4
4
  module Sequel
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "state_machines"
4
+
3
5
  module StateMachines
4
6
  module Sequel
5
7
  class CurrentActorAlreadySet < StateMachines::Error; end
@@ -11,11 +13,12 @@ module StateMachines
11
13
  @event = event
12
14
  @object = obj
13
15
  msg = "#{obj.class}[#{obj.id}] failed to transition on #{event}"
14
- if obj.respond_to?(:audit_logs) && obj.audit_logs.present?
16
+ if obj.respond_to?(:audit_logs) && !obj.audit_logs.empty?
15
17
  @audit_log = obj.audit_logs.max_by(&:id)
16
- msg += ": #{@audit_log.messages.last}"
18
+ msg += ": #{@audit_log.full_message}"
19
+ msg = msg.tr("\n", " ").strip
17
20
  end
18
- super(msg)
21
+ super(obj, msg)
19
22
  end
20
23
  end
21
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-state-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lithic Tech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-06 00:00:00.000000000 Z
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec