activejob-status 0.3.0 → 0.4.0

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: caa59f53f6175aea2f38a219adfd4a707fc3fb8460265aeff78adc7b09a494f2
4
- data.tar.gz: f8775e045b684ba6cc1215e2e7570ba8e7b4f10ad889d7fb5d78bea44a5b62f1
3
+ metadata.gz: 93c7fee3b739316143dadbbc360b14c1557c30e6a83199d606675d4eb5164f7b
4
+ data.tar.gz: eef77191de849b3f4a063569a0b9016c55fb1c94b3c1856d8ed89e69bedb9631
5
5
  SHA512:
6
- metadata.gz: a15529aeaab2bf3e25a5a56fab998e867f9af6fd3f835b788a84f001f9f4be4f974c8e7e2d3d40f8f45b6d764b40984af69a11cc95c9edece1e6e987c8e5dee8
7
- data.tar.gz: 48fa3e3ee20a768007b830b5f5019d958594c4ec26ffd8d0bdb8bcd7d0dbdbd8d6da63408df591bda657b5de93bc991f08f84b7b8076cf699ed86385671d72e2
6
+ metadata.gz: 3bf621c0950c2c55e03d8aca6ffd38e327d0ae4afd5a55d130af80c02e4d81a5dc4557133dd7dd4ee394113ba3e3ebfc831feb268aee2fdc7caef9d2fde6d9b6
7
+ data.tar.gz: d0a5aac3bf768f3c17f396dc09c6386364bea3291862ca6144df032c5d7aacdae0a351347e86ff480dde17d322ad9353e19f64664280a9d27d7503d3aa5e2918
@@ -23,8 +23,10 @@ module ActiveJob
23
23
  alias_method :to_h, :read
24
24
 
25
25
  def update(payload, options = {})
26
- @job.progress.instance_variable_set(:@progress, payload[:progress]) if payload.include?(:progress)
27
- @job.progress.instance_variable_set(:@total, payload[:total]) if payload.include?(:total)
26
+ if @job.respond_to?(:progress)
27
+ @job.progress.instance_variable_set(:@progress, payload[:progress]) if payload.include?(:progress)
28
+ @job.progress.instance_variable_set(:@total, payload[:total]) if payload.include?(:total)
29
+ end
28
30
 
29
31
  @storage.update(@job, payload, **options)
30
32
  end
@@ -56,6 +58,8 @@ module ActiveJob
56
58
  # Update default data
57
59
 
58
60
  def update_defaults(status_key)
61
+ raise "cannot call #update_defaults when status is accessed from outside the job" if @job.is_a?(String)
62
+
59
63
  payload = {}
60
64
  payload[:status] = status_key if @defaults.include?(:status)
61
65
  payload[:serialized_job] = @job.serialize if @defaults.include?(:serialized_job)
@@ -63,10 +67,12 @@ module ActiveJob
63
67
  end
64
68
 
65
69
  def catch_exception(e)
70
+ raise "cannot call #catch_exception when status is accessed from outside the job" if @job.is_a?(String)
71
+
66
72
  payload = {}
67
73
  payload[:status] = :failed if @defaults.include?(:status)
68
74
  payload[:serialized_job] = @job.serialize if @defaults.include?(:serialized_job)
69
- payload[:exception] = {class: e.class.name, message: e.message} if @defaults.include?(:exception)
75
+ payload[:exception] = {class: e.class.name, message: e.original_message} if @defaults.include?(:exception)
70
76
  update(payload, force: true)
71
77
  end
72
78
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveJob
4
4
  module Status
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "active_support/concern"
4
4
  require "active_support/core_ext/hash"
5
+ require "active_support/core_ext/enumerable"
6
+ require "active_job"
5
7
  require "activejob-status/storage"
6
8
  require "activejob-status/status"
7
9
  require "activejob-status/progress"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activejob-status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savater Sebastien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-02 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob