status_workflow 3.0.1 → 3.0.2

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
  SHA1:
3
- metadata.gz: eb9130d6f16327b6b45eede2597c13cde33c20dc
4
- data.tar.gz: '08197cc5822f7b153e01c691d0f21166a1942414'
3
+ metadata.gz: e1429ec0dd19bb00d60a21a13b222e2152d0e61a
4
+ data.tar.gz: 3a418f92be0f9d4ef97722ec7ae420ef0d3ba4e6
5
5
  SHA512:
6
- metadata.gz: 3c5f5b2008ed00ddb9c6f0ace025e0f6ae2753101fae3be9d88d52712551595b3720f7724de94470e13a16bf74e64d6310382c10f15ce9c9cec879f35cf3ec14
7
- data.tar.gz: bef5b253cc517f759915498e7c43ea6d65f75e4e7b99935304fe83d6b60a89c44521f8afb1482bea0fd7c7c4c1ac09eedc234be9a9ce384bc5d36fdc723d8c08
6
+ metadata.gz: 7ba51b05b15489ca77342bb35ad4e179c6fe0a00f5aaccc0c62d25e7b20a43e5eb803b8ff8cc4c6b14dd3f8d3a8952d89acd34cd58a5dc8cba1220fc2e2d382a
7
+ data.tar.gz: 734ce3e74ea19d0dcc96606f6bf513b8ac9e8ac034665d28e374c8a1af8f4eff660822e6cdab218a4cfd10b2c8c1fca6c31d69368f5f46a4c8f60fcac7a84cb1
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 3.0.2 / 2018-11-05
2
+
3
+ Enhancements
4
+
5
+ * Prefix error status with previous status
6
+ * Return the result of the block from status_transition!
7
+
1
8
  3.0.1 / 2018-10-24
2
9
 
3
10
  Enhancements
@@ -23,6 +23,7 @@ module StatusWorkflow
23
23
  LOCK_CHECK_RATE = 0.2
24
24
 
25
25
  def status_transition!(intermediate_to_status, final_to_status, prefix = nil)
26
+ result = nil # what the block yields, return to the user
26
27
  intermediate_to_status = intermediate_to_status&.to_s
27
28
  final_to_status = final_to_status&.to_s
28
29
  prefix_ = prefix ? "#{prefix}_" : nil
@@ -58,11 +59,12 @@ module StatusWorkflow
58
59
  sleep LOCK_EXPIRY/2.0
59
60
  end
60
61
  end
61
- yield
62
+ result = yield
62
63
  rescue
63
64
  # If the block errors, set status to error and record the backtrace
64
65
  error = (["#{$!.class} #{$!.message}"] + $!.backtrace).join("\n")
65
- update_columns status_column => 'error', status_changed_at_column => Time.now, error_column => error
66
+ status = read_attribute status_column
67
+ update_columns status_column => "#{status}_error", status_changed_at_column => Time.now, error_column => error
66
68
  raise
67
69
  end
68
70
  end
@@ -77,7 +79,7 @@ module StatusWorkflow
77
79
  StatusWorkflow.redis.del lock_key
78
80
  heartbeat.kill if heartbeat
79
81
  end
80
- true
82
+ result
81
83
  end
82
84
 
83
85
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module StatusWorkflow
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: status_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-24 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis