async_block 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async_block/version.rb +1 -1
- data/lib/async_block.rb +6 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 649539d48c1563da8a4b0143cb24b75de2421bd58c212709e81adae060dc90bc
|
4
|
+
data.tar.gz: a6ad28a0638afb9fe4e70b61b3743bd4575dca868413a59c673aee00f554fe89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ac6a453f468c8d02365547aa28817b6d1de1eb631419f046a94a94948e0daf6eb6b2c2775aab263d994e76a3086fc3199f8db17f790a50c888c52a96a84fd06
|
7
|
+
data.tar.gz: 274be67b6c81b6fc04f02f702c84ec3ea44d33fa03540355f378df2ea9a79a553a1c5833368cd46c8ab1e20594ae1f30bdf9a023b622e949b97b6bc195ba2a01
|
data/lib/async_block/version.rb
CHANGED
data/lib/async_block.rb
CHANGED
@@ -11,10 +11,12 @@ module AsyncBlock
|
|
11
11
|
def self.run(queue: nil, delay: nil, &block)
|
12
12
|
source = BlockToSource.new(block).convert
|
13
13
|
queue ||= DEFAULT_QUEUE_NAME
|
14
|
-
if delay.instance_of?(ActiveSupport::Duration)
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
delay = nil if delay.present? && !delay.instance_of?(ActiveSupport::Duration)
|
15
|
+
response = {}
|
16
|
+
AsyncWrapperJob.set(wait: delay, queue: queue.to_sym).perform_later(source) do |job|
|
17
|
+
response[:enqueued] = job.successfully_enqueued?
|
18
|
+
response[:job] = job
|
18
19
|
end
|
20
|
+
response
|
19
21
|
end
|
20
22
|
end
|