resque-better_unique 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49c3786567e5fac7afaf1952494e57dab802498c
4
- data.tar.gz: c2c493ae52134c85d258f263f8da2a64e35ab843
3
+ metadata.gz: e474de20786fbba4361851c129a2644738ca9bda
4
+ data.tar.gz: b887e51072a2ce8756536f1b7aed2fef67cbfc02
5
5
  SHA512:
6
- metadata.gz: 6718dbab47f5b8f8cd6806981370aba54b36c53369c6126968139f9ea14a1d805e83330cdd646970df77ff096149500728efbf6f902dec2ab6cea16977dd198c
7
- data.tar.gz: b433207f6254cb640c3ed511743fddc4b5b2a07786cb73e2ffb2f068160c00a6d711c4db4f0e034ac04551a63278e31d8143e3ea5d71268b0239d061f2674204
6
+ metadata.gz: d04eeee9e17cf85359eb1b8865c635ae1f92b050a92d589161cb1f9daaef75d86cb3c7a6562ae9ec2ae7aa261d33dc0ea797899569cccf9fe09083d8236cb77e
7
+ data.tar.gz: 0cf12c119b33e5dff88e3036a5ba622e3cef1b446bda3ef57f3c57b64daa588ff00ade9f7e28ed8fcf18ebe7b9678ebc74148bfcc4280116d343f66693709cbd
@@ -12,7 +12,7 @@ module Resque
12
12
  # passed the same arguments as `perform`, that is, your job's
13
13
  # payload.
14
14
  def lock_key(*args)
15
- unique_args = unique_options[:unique_args]
15
+ unique_args = unique_job_options[:unique_args]
16
16
  lock_args = case unique_args
17
17
  when Proc
18
18
  unique_args.call(*args)
@@ -32,24 +32,24 @@ module Resque
32
32
  Resque.redis.exists(lock_key(*args))
33
33
  end
34
34
 
35
- def unique_options
36
- @unique_options || {}
35
+ def unique_job_options
36
+ @unique_job_options || {}
37
37
  end
38
38
 
39
- def unique_options=(options)
40
- @unique_options = options
39
+ def unique_job_options=(options)
40
+ @unique_job_options = options
41
41
  end
42
42
 
43
- def unique_mode
44
- unique_options[:mode].to_sym || :none
43
+ def unique_job_mode
44
+ unique_job_options[:mode].to_sym || :none
45
45
  end
46
46
 
47
- def unique(mode=:until_executed, options={})
48
- self.unique_options = {mode: mode}.merge(options)
47
+ def unique_job(mode=:until_executed, options={})
48
+ self.unique_job_options = {mode: mode}.merge(options)
49
49
  end
50
50
 
51
51
  def before_enqueue_unique_lock(*args)
52
- if [:until_executing, :until_executed, :until_timeout].include?(unique_mode)
52
+ if [:until_executing, :until_executed, :until_timeout].include?(unique_job_mode)
53
53
  return false if locked?(*args)
54
54
  set_lock(*args)
55
55
  end
@@ -57,7 +57,7 @@ module Resque
57
57
  end
58
58
 
59
59
  def around_perform_unique_lock(*args)
60
- case unique_mode
60
+ case unique_job_mode
61
61
  when :until_executing
62
62
  release_lock(*args)
63
63
  when :while_executing
@@ -65,7 +65,7 @@ module Resque
65
65
  end
66
66
  yield
67
67
  ensure
68
- if [:until_executed, :while_executing].include?(unique_mode)
68
+ if [:until_executed, :while_executing].include?(unique_job_mode)
69
69
  release_lock(*args)
70
70
  end
71
71
  end
@@ -76,8 +76,8 @@ module Resque
76
76
 
77
77
  def set_lock(*args)
78
78
  is_now_locked = Resque.redis.setnx(lock_key(*args), true)
79
- if is_now_locked && unique_options[:timeout]
80
- Resque.redis.expire(lock_key(*args), unique_options[:timeout].to_i)
79
+ if is_now_locked && unique_job_options[:timeout]
80
+ Resque.redis.expire(lock_key(*args), unique_job_options[:timeout].to_i)
81
81
  end
82
82
  is_now_locked
83
83
  end
@@ -1,7 +1,7 @@
1
1
  module Resque
2
2
  module Plugins
3
3
  module BetterUnique
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-better_unique
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
  - Will Bryant