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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c6e38b8eba31d3f7ad7da0e059939ca00e52a082179db6e5c15b266274cbe5d
4
- data.tar.gz: 11141c0ffd733631143b4a1b042d6e022a1d54b1ec80eacb8b1ef525138215fe
3
+ metadata.gz: d895db87072be887179ce6110bdc54801e0b56a23a4121c2b7c843ba4471c3c0
4
+ data.tar.gz: 773bc76a3bf145241a0b1206841f292f8e9f9caee787c9e1a1085e40eff72bb3
5
5
  SHA512:
6
- metadata.gz: 3efd5c6629a9c4946f5987928012f02d5de8a054b3f9ab88d31f1130f811d25040ee83931c499014e9448775e727d6b29614ffb5f9d9ef3636f4277e2608c70a
7
- data.tar.gz: 87e838de89cf0511ee9178dfd4d5314b9fb88262c166bf5fa7e0f4f8e34f4224e1998c1c321637c76e3fc5810742bfdac33bda6e62a5fbb9dac13db23f96db51
6
+ metadata.gz: '03097a86057f84f07750e15bb7a0efcca3b7bcfd95e6fe71ce78a79eefc6bdce00035210e685b0b61a0cfeb1f18ceae7676fb4d9f06e9734f8d658edb2a51c77'
7
+ data.tar.gz: b6ba970874a73914255dc4d32bb96945b459fc5ba2ada0688bd908107043daf4f1febb885a2b151c44e6b0d1e35fdd2d96600c564bc4736b779c0db85f8b972e
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # require 'sourcify'
4
- # require 'method_source'
3
+ require 'sourcify'
4
+ require 'method_source'
5
5
 
6
6
  module AsyncBlock
7
7
  # BlockToSource - converts code block to source string
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsyncBlock
4
- VERSION = '0.2.9'
4
+ VERSION = '0.3.1'
5
5
  end
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
- AsyncWrapperJob.set(wait: delay, queue: queue.to_sym).perform_later(source)
16
- else
17
- AsyncWrapperJob.set(queue: queue.to_sym).perform_later(source)
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
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.9
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adittya Dey