active_job-performs 1.0.0 → 1.0.2

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
  SHA256:
3
- metadata.gz: b542fb6dfc15013d7394abe349150c20db3555df4cffe45ad46eff3500a6ec83
4
- data.tar.gz: d21f76499f2707f10655ed18b6c89aa490085c49ad06d466c12fa3c259769c3a
3
+ metadata.gz: 0a72e3cc5d848627d02f6254e60c6997a528e4ab43ce615efc05bfd4d1ff4c5e
4
+ data.tar.gz: 83d9462c0c2b4434dac5c1cc886325c7f245332d85e8eaf0141acf35796cbb35
5
5
  SHA512:
6
- metadata.gz: 39cb92fa643259199b33fda49cac8dc9dc68e288a617bc21ed6dbdd2bb339ac6fe593114bbf63f19922723480045d543d3a7510d2076e159ed20fdf440b4e171
7
- data.tar.gz: da7067a2209a9de743b29d868063f1701a588e6b9ab56843fc09606be7bcc392fcd1f72fa14fc1ff111657c692d72d2f05cda42863ac87580bda7ec1eecb6289
6
+ metadata.gz: bf84c360ee4581cccda1cc7518c4e46919e9cd9158c96c429cd2b28a2f656176841c32cc815e57a409cfd69404418108c7b1af5040eec8187a17348d60a02db5
7
+ data.tar.gz: de200e317f8e075404cc9575b896d9c3d174c48724da1190d3dbb0e12f74d405a187f87dc5a859e9b9f905a6f661216aa847bc3ab10b6826e930a188185917c9
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_job-performs (1.0.0)
4
+ active_job-performs (1.0.2)
5
5
  activejob (>= 6.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -308,6 +308,8 @@ class Post < ActiveRecord::Base
308
308
 
309
309
  # Additionally, a block can be passed to have access to the `post`:
310
310
  performs :social_media_boost, wait: -> post { post.social_media_boost_grace_period }
311
+ performs :social_media_boost, wait: :social_media_boost_grace_period # The symbol version also supports calling private methods
312
+ def social_media_boost_grace_period = 5.minutes
311
313
  end
312
314
  ```
313
315
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveJob
4
4
  module Performs
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
@@ -8,11 +8,11 @@ module ActiveJob::Performs
8
8
  attr_reader :wait, :wait_until
9
9
 
10
10
  def wait=(value)
11
- @wait = value.respond_to?(:call) ? value : proc { value }
11
+ @wait = normalize_wait(value)
12
12
  end
13
13
 
14
14
  def wait_until=(value)
15
- @wait_until = value.respond_to?(:call) ? value : proc { value }
15
+ @wait_until = normalize_wait(value)
16
16
  end
17
17
 
18
18
  def scoped_by_wait(record)
@@ -22,6 +22,18 @@ module ActiveJob::Performs
22
22
  self
23
23
  end
24
24
  end
25
+
26
+ private
27
+ def normalize_wait(value)
28
+ case value
29
+ when Symbol
30
+ proc { _1.send value }
31
+ when Proc
32
+ value.arity.zero? ? proc { value.call } : value
33
+ else
34
+ proc { value }
35
+ end
36
+ end
25
37
  end
26
38
 
27
39
  def performs(method = nil, **configs, &block)
@@ -60,7 +72,7 @@ module ActiveJob::Performs
60
72
 
61
73
  private
62
74
  def safe_define(name)
63
- name.safe_constantize || const_set(name, Class.new(yield))
75
+ const_defined?(name, false) ? const_get(name, false) : const_set(name, Class.new(yield))
64
76
  end
65
77
 
66
78
  def apply_performs_to(job, **configs, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_job-performs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Timm Hansen
@@ -29,6 +29,7 @@ executables: []
29
29
  extensions: []
30
30
  extra_rdoc_files: []
31
31
  files:
32
+ - ".ruby-version"
32
33
  - CHANGELOG.md
33
34
  - Gemfile
34
35
  - Gemfile.lock