state_machines 0.100.1 → 0.100.2

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: a87715920a8f37a43cbac61b18e9a1c91d72b4b2d2228c3dc275dc05781efe9f
4
- data.tar.gz: 7e098b96739caf0b91010ae21c626109b58fbd7325bfa309c0518055e040bcbb
3
+ metadata.gz: b240916b3b1592fd9980f8dc7583dac5b9af93cf38c193ffb6e2427f3f15f6c0
4
+ data.tar.gz: ea38fc11bd6619335415d3a90b92f7f5909df03e5fd087aaf14716dca977d847
5
5
  SHA512:
6
- metadata.gz: 7c4905db4ba8245378cb89118143432d0fd009cefbef97846bbd12608c2dbb8b55627dceb71c2a044933acb3aeae4d57c21aa16c687b32883e18789b207da088
7
- data.tar.gz: 3031f999997380d3def3b379ef794639463a2b0c82913e08f8829374fe5707ea36076e999965719db4dadcd31f8c9890fd40ff4bf6db9a3b2d081d99a771efe5
6
+ metadata.gz: 80517f65fa434f346e552677e08cdd6b04e3d573eef756d058645a4d067bb1dd21331d86d657b0df429cfc3157d48cff3bfe594bb7bcb79f4a34b89cf880150c
7
+ data.tar.gz: '01874fcbb634ec7daf80bd3a5d87169644916ebb71e4bbfaaf1891ce53beac963261e2684df288b8aaedf057dae66e64f3167bdd6a676b095562096edbf25c42'
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StateMachines
4
+ # Module to extend Fiber instances for pausable state tracking
5
+ module PausableFiber
6
+ attr_accessor :state_machine_fiber_pausable
7
+ end
8
+
4
9
  # A transition represents a state change for a specific attribute.
5
10
  #
6
11
  # Transitions consist of:
@@ -397,7 +402,8 @@ module StateMachines
397
402
  # Create a new fiber to run the block
398
403
  fiber = Fiber.new do
399
404
  # Mark that we're inside a pausable fiber
400
- Thread.current[:state_machine_fiber_pausable] = true
405
+ Fiber.current.extend(StateMachines::PausableFiber)
406
+ Fiber.current.state_machine_fiber_pausable = true
401
407
  begin
402
408
  halted = !catch(:halt) do
403
409
  yield
@@ -409,7 +415,7 @@ module StateMachines
409
415
  [:error, e]
410
416
  ensure
411
417
  # Clean up the flag
412
- Thread.current[:state_machine_fiber_pausable] = false
418
+ Fiber.current.state_machine_fiber_pausable = false
413
419
  end
414
420
  end
415
421
 
@@ -448,8 +454,9 @@ module StateMachines
448
454
  return if @resuming
449
455
 
450
456
  # Only yield if we're actually inside a fiber created by pausable
451
- # We use a thread-local variable to track this
452
- return unless Thread.current[:state_machine_fiber_pausable]
457
+ # We use a module extension to track this
458
+ current_fiber = Fiber.current
459
+ return unless current_fiber.respond_to?(:state_machine_fiber_pausable) && current_fiber.state_machine_fiber_pausable
453
460
 
454
461
  Fiber.yield
455
462
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StateMachines
4
- VERSION = '0.100.1'
4
+ VERSION = '0.100.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.100.1
4
+ version: 0.100.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.6.7
138
+ rubygems_version: 3.6.9
139
139
  specification_version: 4
140
140
  summary: State machines for attributes
141
141
  test_files: []