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 +4 -4
- data/lib/state_machines/transition.rb +11 -4
- data/lib/state_machines/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b240916b3b1592fd9980f8dc7583dac5b9af93cf38c193ffb6e2427f3f15f6c0
|
4
|
+
data.tar.gz: ea38fc11bd6619335415d3a90b92f7f5909df03e5fd087aaf14716dca977d847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
452
|
-
|
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
|
|
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.
|
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.
|
138
|
+
rubygems_version: 3.6.9
|
139
139
|
specification_version: 4
|
140
140
|
summary: State machines for attributes
|
141
141
|
test_files: []
|