delayable 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +6 -3
- data/lib/delayable/version.rb +1 -1
- data/lib/delayable.rb +16 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23e567b9c922ccd54bb09dc460d63597581559481fc136ef3aff722d7294f4e1
|
4
|
+
data.tar.gz: e336c91c328a3efa8311d1bb4b8eef85abc0b8138f92ef311f393a65b68360a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4759ae5a84432a6f7a3fa199c05252ebfa21daf06920880c1bbe5ce38aa060b7b5fc78759b3630386d0ba042d58077bc64c10f22ee2069234d9a80b687a6f5c3
|
7
|
+
data.tar.gz: '09bfdd9365b70492b8f9d2bee9ae96f775cb36f4d30a5461dca84808cb226be43d809f9f8512cdd0253e697b04907a35bcaef4d41fce8bad8dc942c9d5a16d3f'
|
data/Rakefile
CHANGED
data/lib/delayable/version.rb
CHANGED
data/lib/delayable.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
require "active_support/core_ext/string/inflections"
|
3
|
+
|
1
4
|
require "delayable/version"
|
2
5
|
|
3
6
|
module Delayable
|
4
7
|
extend ActiveSupport::Concern
|
5
8
|
|
9
|
+
included do
|
10
|
+
fail "Please define ApplicationJob before including Delayable" unless defined?(ApplicationJob)
|
11
|
+
fail "Please define Current before including Delayable" unless defined?(Current)
|
12
|
+
end
|
13
|
+
|
6
14
|
class_methods do
|
7
15
|
def delay(method_name, class_method: false, wait: nil, limits_concurrency: nil, queue: :default)
|
8
16
|
job = const_set(delayable_job_name(method_name, class_method:),
|
@@ -34,12 +42,18 @@ module Delayable
|
|
34
42
|
end
|
35
43
|
|
36
44
|
def delayable_job_name(method_name, class_method: false)
|
37
|
-
|
45
|
+
class_name = bang_method?(method_name) ? "#{method_name.to_s.chomp('!').camelize}Bang" : method_name.to_s.camelize
|
46
|
+
:"#{'Class' if class_method}#{class_name}Job"
|
38
47
|
end
|
39
48
|
|
40
49
|
def delayable_define_method(class_method:, method_name:, &block)
|
41
50
|
define_method_type = class_method ? :define_singleton_method : :define_method
|
42
|
-
|
51
|
+
method_name = bang_method?(method_name) ? "#{method_name.to_s.chomp('!')}_later!" : "#{method_name}_later"
|
52
|
+
public_send(define_method_type, method_name, &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
def bang_method?(method_name)
|
56
|
+
method_name.to_s.end_with?('!')
|
43
57
|
end
|
44
58
|
end
|
45
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trae Robrock
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|