async_block 0.2.5 → 0.2.6
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 +3 -8
- 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: 18e0e1824a1ab945b463420a2e016fdbe18f6d43495ca65709f4a52c74f0e745
|
4
|
+
data.tar.gz: b60005b7644181beb5758ad9414439901dfa93ce58b860095a065b59c98eb06b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca350e098475197eba58efabd2e995a99e113c9b74504f78756e998cf38b8442af317b77ac9c93e519ce5e98c6a02e6e5dc549c6846ac1b487ffce6cdbd0d51
|
7
|
+
data.tar.gz: 62c2ce631bda1ab60f14b1fd832ddda2742730699669061ca8d634b4cec297f7114dd4c5ffc552b37d3f1af925577ab661f68255a10373babaf517b5254979e2
|
data/lib/async_block/version.rb
CHANGED
data/lib/async_block.rb
CHANGED
@@ -10,18 +10,13 @@ require_relative 'async_block/async_wrapper_job'
|
|
10
10
|
module AsyncBlock
|
11
11
|
class Error < StandardError; end
|
12
12
|
|
13
|
-
def self.perform(queue: nil, delay: nil,
|
13
|
+
def self.perform(queue: nil, delay: nil, &block)
|
14
14
|
source = BlockToSource.new(block).convert
|
15
|
-
on_error_source = BlockToSource.new(on_error || default_on_error).convert
|
16
15
|
queue ||= DEFAULT_QUEUE_NAME
|
17
16
|
if delay.instance_of?(ActiveSupport::Duration)
|
18
|
-
AsyncWrapperJob.set(wait: delay, queue: queue.to_sym).perform_later(source
|
17
|
+
AsyncWrapperJob.set(wait: delay, queue: queue.to_sym).perform_later(source)
|
19
18
|
else
|
20
|
-
AsyncWrapperJob.set(queue: queue.to_sym).perform_later(source
|
19
|
+
AsyncWrapperJob.set(queue: queue.to_sym).perform_later(source)
|
21
20
|
end
|
22
21
|
end
|
23
|
-
|
24
|
-
def self.default_on_error(error_message)
|
25
|
-
puts('AsyncBlockError', error_message)
|
26
|
-
end
|
27
22
|
end
|