lev 12.0.0 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9b8ecaa0018e8014f478eff02949764ffaf1ad73f50c9d64be7fd6889b9758d
4
- data.tar.gz: ff47d80e42f5ef65335c4da2636efe6ee0bc13a78a650b1b13833e5e1aa84763
3
+ metadata.gz: 36f2d078f5b053db33b4943cc4ea446fcb55144c75138f0b6218a86bb91a0173
4
+ data.tar.gz: 7cd0f512ca30c4d729ab21b4fb3a026acb4f7862c0ab1c91b0af6c9c47473ea0
5
5
  SHA512:
6
- metadata.gz: 858c6dba66a94ba31b6129f3602d55d83e7cc713fe9a7710f3e6109c7e80cb3cc67a568c4257d9d44d32c90c10c17d943700ef36e9eed1e82b114ca9f5fa9f9c
7
- data.tar.gz: 74bdcc356356641f04717adbcf74c7c3945522ab0b472ed8eef4cba407f55022cea2541092c4bca0a70deac1cb3d730454a1d98dfcf28a73e631abc6a3c41157
6
+ metadata.gz: 4bb1482577a5d79fdd4d6158dbd806be1d39a6e959d4f7fca8c99648ce7959348b21f229a42891dc7d1a9fabca7583a726fb7ab153387e8d2d30645163d271d3
7
+ data.tar.gz: 6bc07ed4006f3a315b72e37e3a9adf33918dbe98071222a5607f6bf4e0cfe09cb0499419bf4321e25c8f32a0001b729053a0b3bf83e206314703a4b656b43205
@@ -3,7 +3,7 @@ module Lev
3
3
  class Base < Lev.configuration.job_class
4
4
  attr_accessor(:provider_job_id) unless respond_to?(:provider_job_id)
5
5
 
6
- def perform_later(routine_class, options, *args, &block)
6
+ def perform_later(routine_class, options, *args, **kwargs, &block)
7
7
  # Create a new status object
8
8
  status = routine_class.create_status
9
9
 
@@ -25,7 +25,7 @@ module Lev
25
25
  # Queue up the job and set the provider_job_id
26
26
  # For delayed_job, requires either Rails 5 or
27
27
  # http://stackoverflow.com/questions/29855768/rails-4-2-get-delayed-job-id-from-active-job
28
- provider_job_id = self.class.send(:job_or_instantiate, *args, &block)
28
+ provider_job_id = self.class.send(:job_or_instantiate, *args, **kwargs, &block)
29
29
  .enqueue(options)
30
30
  .provider_job_id
31
31
  status.set_provider_job_id(provider_job_id) \
@@ -35,14 +35,14 @@ module Lev
35
35
  status.id
36
36
  end
37
37
 
38
- def perform(*args, &block)
38
+ def perform(*args, **kwargs, &block)
39
39
  # Pop arguments added by perform_later
40
40
  id = args.pop
41
41
  routine_class = Kernel.const_get(args.pop)
42
42
 
43
43
  routine_instance = routine_class.new(routine_class.find_status(id))
44
44
 
45
- routine_instance.call(*args, &block)
45
+ routine_instance.call(*args, **kwargs, &block)
46
46
  end
47
47
  end
48
48
  end
@@ -12,8 +12,8 @@ module Lev
12
12
  routine_class.active_job_enqueue_options.merge(@options)
13
13
  end
14
14
 
15
- def perform_later(*args, &block)
16
- routine_class.job_class.new.perform_later(routine_class, options, *args, &block)
15
+ def perform_later(*args, **kwargs, &block)
16
+ routine_class.job_class.new.perform_later(routine_class, options, *args, **kwargs, &block)
17
17
  end
18
18
  end
19
19
  end
@@ -14,7 +14,7 @@ class Lev::NullStatus
14
14
  @kill_requested
15
15
  end
16
16
 
17
- def method_missing(*args, &block)
17
+ def method_missing(*args, **kwargs, &block)
18
18
  nil
19
19
  end
20
20
 
data/lib/lev/routine.rb CHANGED
@@ -200,12 +200,12 @@ module Lev
200
200
  end
201
201
 
202
202
  module ClassMethods
203
- def call(*args, &block)
204
- new.call(*args, &block)
203
+ def call(*args, **kwargs, &block)
204
+ new.call(*args, **kwargs, &block)
205
205
  end
206
206
 
207
- def [](*args, &block)
208
- result = call(*args, &block)
207
+ def [](*args, **kwargs, &block)
208
+ result = call(*args, **kwargs, &block)
209
209
  result.errors.raise_exception_if_any!
210
210
  result.outputs.send(@express_output)
211
211
  end
@@ -222,9 +222,9 @@ module Lev
222
222
  @active_job_enqueue_options || { queue: :default }
223
223
  end
224
224
 
225
- def perform_later(*args, &block)
225
+ def perform_later(*args, **kwargs, &block)
226
226
  # Delegate to a subclass of Lev::Routine::ActiveJob::Base
227
- job_class.new.perform_later(self, active_job_enqueue_options, *args, &block)
227
+ job_class.new.perform_later(self, active_job_enqueue_options, *args, **kwargs, &block)
228
228
  end
229
229
 
230
230
  # Called at a routine's class level to foretell which other routines will
@@ -279,7 +279,7 @@ module Lev
279
279
 
280
280
  attr_reader :runner
281
281
 
282
- def call(*args, &block)
282
+ def call(*args, **kwargs, &block)
283
283
  @after_transaction_blocks = []
284
284
 
285
285
  status.started!
@@ -290,9 +290,9 @@ module Lev
290
290
 
291
291
  catch :fatal_errors_encountered do
292
292
  if self.class.delegates_to
293
- run(self.class.delegates_to, *args, &block)
293
+ run(self.class.delegates_to, *args, **kwargs, &block)
294
294
  else
295
- exec(*args, &block)
295
+ exec(*args, **kwargs, &block)
296
296
  end
297
297
  end
298
298
  end
@@ -324,7 +324,7 @@ module Lev
324
324
  who == topmost_runner && who.class.transaction_isolation != TransactionIsolation.no_transaction
325
325
  end
326
326
 
327
- def run(other_routine, *args, &block)
327
+ def run(other_routine, *args, **kwargs, &block)
328
328
  options = {}
329
329
 
330
330
  if other_routine.is_a? Array
@@ -395,7 +395,7 @@ module Lev
395
395
  #
396
396
 
397
397
  other_routine.runner = self
398
- run_result = other_routine.call(*args, &block)
398
+ run_result = other_routine.call(*args, **kwargs, &block)
399
399
 
400
400
  run_result.outputs.transfer_to(outputs) do |name|
401
401
  output_mapper.map(name)
@@ -495,7 +495,15 @@ module Lev
495
495
  def in_transaction(options={})
496
496
  if transaction_run_by?(self)
497
497
  isolation_symbol = self.class.transaction_isolation.symbol
498
- if ActiveRecord::VERSION::MAJOR >= 4
498
+ if (ActiveRecord::VERSION::MAJOR >= 8 ||
499
+ (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1)) &&
500
+ ActiveRecord::Base.connection.transaction_open?
501
+ # Don't even try to set transaction isolation if the transaction is already open
502
+ ActiveRecord::Base.transaction do
503
+ yield
504
+ raise ActiveRecord::Rollback if errors?
505
+ end
506
+ elsif ActiveRecord::VERSION::MAJOR >= 4
499
507
  begin
500
508
  ActiveRecord::Base.transaction(isolation: isolation_symbol) do
501
509
  yield
data/lib/lev/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lev
2
- VERSION = '12.0.0'
2
+ VERSION = '12.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lev
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.0
4
+ version: 12.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-14 00:00:00.000000000 Z
11
+ date: 2024-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack