async_block 0.2.9 → 0.3.1
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/block_source_service.rb +2 -2
- data/lib/async_block/version.rb +1 -1
- data/lib/async_block.rb +8 -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: d895db87072be887179ce6110bdc54801e0b56a23a4121c2b7c843ba4471c3c0
|
4
|
+
data.tar.gz: 773bc76a3bf145241a0b1206841f292f8e9f9caee787c9e1a1085e40eff72bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '03097a86057f84f07750e15bb7a0efcca3b7bcfd95e6fe71ce78a79eefc6bdce00035210e685b0b61a0cfeb1f18ceae7676fb4d9f06e9734f8d658edb2a51c77'
|
7
|
+
data.tar.gz: b6ba970874a73914255dc4d32bb96945b459fc5ba2ada0688bd908107043daf4f1febb885a2b151c44e6b0d1e35fdd2d96600c564bc4736b779c0db85f8b972e
|
data/lib/async_block/version.rb
CHANGED
data/lib/async_block.rb
CHANGED
@@ -11,10 +11,14 @@ 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
|
+
enqueued: false,
|
17
|
+
job: nil
|
18
|
+
}
|
19
|
+
AsyncWrapperJob.set(wait: delay, queue: queue.to_sym).perform_later(source) do |job|
|
20
|
+
response[:enqueued] = job.successfully_enqueued?
|
21
|
+
response[:job] = job
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|