active_job-performs 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
  SHA256:
3
- metadata.gz: b542fb6dfc15013d7394abe349150c20db3555df4cffe45ad46eff3500a6ec83
4
- data.tar.gz: d21f76499f2707f10655ed18b6c89aa490085c49ad06d466c12fa3c259769c3a
3
+ metadata.gz: 98388c4ee6fae085e8fca9635ac1e02781c612b5481c89f12f83e0b73884a834
4
+ data.tar.gz: 646fc3cf2ec5b002168d817eee80ab911e635595a6c5b702784bb7685075353f
5
5
  SHA512:
6
- metadata.gz: 39cb92fa643259199b33fda49cac8dc9dc68e288a617bc21ed6dbdd2bb339ac6fe593114bbf63f19922723480045d543d3a7510d2076e159ed20fdf440b4e171
7
- data.tar.gz: da7067a2209a9de743b29d868063f1701a588e6b9ab56843fc09606be7bcc392fcd1f72fa14fc1ff111657c692d72d2f05cda42863ac87580bda7ec1eecb6289
6
+ metadata.gz: ec5540e89046e0e76114467ed9f0890e2133d9c6877cbb6522cd202f931ddc71a79a13fddc5a70faa22a33ec7e8a77170cbd767a8c9a0ab1355358d59fd7ea85
7
+ data.tar.gz: 5bd6b34a001a436c1e795e86c819a48e56ee0b8eab2c962b59c8d16bd8e0924b4b9d709c3543a9c2047970600a7c74a60a8cc7c480da2672d8d60453e3f6feaf
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.1)
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.1"
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)
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.1
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