async_block 0.2.5 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7539642e1592d011a2ee73df80be6fe4302c9305d27fcf4a6b8a3c45e8057a1
4
- data.tar.gz: a983837e94527782bfa72cd385c2c071279f0e66d14f926666f924e40353390c
3
+ metadata.gz: 2130f23729cead7cdd271b467edc3f5ab940cb2dd121e7b0bdeb6e4b37fa1eb1
4
+ data.tar.gz: 8e7d3d8321f8575d64781aa1b61518d7ffbfe4fd9cbd8a63f45a4317fe8c606a
5
5
  SHA512:
6
- metadata.gz: e79a665d16ea24da30611193955a7e74682a0c653d1833b4dac9d39fe1457db075cd846510206b427a297b75d7fd0ba9b42dbfd33a64417d362bb9c44dc33a92
7
- data.tar.gz: d0ae0f6f9d1ea187f1128fa3a9ffcb0087c54d621b50ed9989119de2f5d53e8999fbca83c2cebb67c17c65b79de259b28221dfd4c6bcbaba55c945e24933a8d5
6
+ metadata.gz: 2034c98fa200ee440f9cec18cf4b78892798048739af52dcede0b01c6fbe7282bec4e9b346843f6f13d3661a9d012773ac722af2e28d3e95020c27e8644088de
7
+ data.tar.gz: d93484c7759261ae68290bc7bbdf6c6a6961ee6dc857b8d42b981fe7fe3399fb9a4d4a98352bec3efa32ccfc741f44521f03467c2aa1b0b11e45f7faeadc4b0e
data/README.md CHANGED
@@ -18,7 +18,7 @@ Add your code in wrapped inside AsyncBlock as described below.
18
18
  \*\* NOTE - AsyncBlock cannot be executed from irb/console
19
19
 
20
20
  ```
21
- AsyncBlock.perform do
21
+ AsyncBlock.run do
22
22
  puts('This is running in a temporary job')
23
23
  puts('Put your code below')
24
24
  end
@@ -27,7 +27,7 @@ end
27
27
  To put some delay on the async execution (say 5 minutes):
28
28
 
29
29
  ```
30
- AsyncBlock.perform(delay: 5.minutes) do
30
+ AsyncBlock.run(delay: 5.minutes) do
31
31
  puts('This is running in a temporary job')
32
32
  puts('Put your code below')
33
33
  end
@@ -36,7 +36,7 @@ end
36
36
  To explicitly mention a queue for the async execution:
37
37
 
38
38
  ```
39
- AsyncBlock.perform(delay: 1.minute, queue: 'p3') do
39
+ AsyncBlock.run(delay: 1.minute, queue: 'p3') do
40
40
  puts('This is running in a temporary job')
41
41
  puts('Put your code below')
42
42
  end
@@ -21,7 +21,7 @@ module AsyncBlock
21
21
  end
22
22
 
23
23
  def execute_block!(block)
24
- block.call
24
+ block&.call
25
25
  end
26
26
  end
27
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsyncBlock
4
- VERSION = '0.2.5'
4
+ VERSION = '0.2.7'
5
5
  end
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, on_error: nil, &block)
13
+ def self.run(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, on_error_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, on_error_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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adittya Dey