stateful.rb 2.3.1 → 2.3.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: 07c897617cdd223bd354d7f7819341cd8dfd388bf412b479fcac7b757e76d004
4
- data.tar.gz: 6742bb2396d64fcac9ee8678b32b187d5b020fc2757842bc79f3f790f5a9a26f
3
+ metadata.gz: 045517b47c6e558d4e414bc639973934c27abc955a5d6281088c3413c38e9a9b
4
+ data.tar.gz: db57952692bd309d8389c6d02de659c5dc3a0ab6ac361ecd491aeba5db3860e4
5
5
  SHA512:
6
- metadata.gz: 1b396504ea4e1ad2f9f1e9c8419d8463749321e8e3ab64433c2cbbd7559377b2750a559099d25ab1e02c398cae2b20f3ec380cb27f83498b8808ddb0a7b4cbe0
7
- data.tar.gz: eaf13d432db2b8df6f7785b009b2c837b434e051e01e318f3e82f497045b0c91af0cf02700f222c372a00478b093c4c98dd3c77f911550393ab8b8b1a89932c7
6
+ metadata.gz: 2ffcb05702b938f0f62d2d661adea0cdc64017eadcb3d6e328c369d88c8655f193ab58b2508706ed8ae3a7b71c0c09805a19bc8212493057b96a46d75e89fed5
7
+ data.tar.gz: bc0e1b4772f7e30f32df35542df5264c4ebe90c6d94ad52009362647f0c98a5450d9c9c303f5c87cfb0140ee03b7c81998ce492d19f85ed38e07ff3a3172772e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # stateful/CHANGELOG.md
2
2
 
3
+ ## 2.3.2 (20260418): Add Sequel examples to README.
4
+ -----------------------------------------------------------------------------------------------------------------------
5
+
6
+ ### ~
7
+ 1. README.md: + Sequel examples (sections 5 and 6), updated description to include Sequel,
8
+ renumbered remaining sections.
9
+ 2. lib/Stateful/VERSION.rb: /2.3.1/2.3.2/
10
+
11
+
3
12
  ## 2.3.1 (20260418): Use require\_relative in tests.
4
13
  -----------------------------------------------------------------------------------------------------------------------
5
14
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Description
4
4
 
5
- A Ruby state machine which allows you to easily add state to Poro and ActiveRecord objects. Works with both CRuby and mRuby.
5
+ A Ruby state machine which allows you to easily add state to Poro, ActiveRecord, and Sequel objects. Works with both CRuby and mRuby.
6
6
 
7
7
  ## Installation
8
8
 
@@ -149,9 +149,67 @@ active_record_machine.final_state?
149
149
  # => true
150
150
  ```
151
151
 
152
- ### 5. Custom variable/column name and non-deterministic event ordering
152
+ ### 5. Sequel with persistence-specific extend and a stateful block declaration
153
153
 
154
- It's also possible to define a state machine (either Poro or ActiveRecord) which has a custom variable (Poro) or column (ActiveRecord) name, which fires off the events in a random or non-deterministic order, and which has no final state.
154
+ ```ruby
155
+ class SequelMachine < Sequel::Model
156
+ extend Stateful::Sequel
157
+
158
+ stateful do
159
+ initial_state :initial_state
160
+
161
+ state :initial_state do
162
+ on :an_event => :next_state
163
+ on :another_event => :final_state
164
+ end
165
+
166
+ state :next_state do
167
+ on :yet_another_event => :final_state
168
+ end
169
+
170
+ final_state :final_state
171
+ end
172
+ end
173
+
174
+ sequel_machine = SequelMachine.create
175
+ sequel_machine.initial_state?
176
+ # => true
177
+ sequel_machine.an_event
178
+ sequel_machine.next_state?
179
+ # => true
180
+ ```
181
+
182
+ ### 6. Sequel with persistence non-specific extend, without a stateful block declaration, an initial_state block, and multiple final states
183
+
184
+ ```ruby
185
+ class SequelMachine < Sequel::Model
186
+ extend Stateful
187
+
188
+ initial_state :initial_state do
189
+ on :an_event => :next_state
190
+ on :another_event => :final_state0
191
+ end
192
+
193
+ state :next_state do
194
+ on :yet_another_event => :final_state0
195
+ on :and_yet_another_event => :final_state1
196
+ end
197
+
198
+ final_state :final_state0, :final_state1
199
+ end
200
+
201
+ sequel_machine = SequelMachine.create
202
+ sequel_machine.an_event
203
+ sequel_machine.final_state?
204
+ # => false
205
+ sequel_machine.yet_another_event
206
+ sequel_machine.final_state?
207
+ # => true
208
+ ```
209
+
210
+ ### 7. Custom attribute name and non-deterministic event ordering
211
+
212
+ It's also possible to define a state machine which has a custom attribute name, which fires off the events in a random or non-deterministic order, and which has no final state.
155
213
 
156
214
  ```ruby
157
215
  class ActiveRecordMachine < ActiveRecord::Base
@@ -285,7 +343,7 @@ class Order
285
343
  end
286
344
  ```
287
345
 
288
- For ActiveRecord, each machine uses a column named `<machine_name>_state`:
346
+ For ActiveRecord and Sequel, each machine uses a column named `<machine_name>_state`:
289
347
 
290
348
  ```ruby
291
349
  class CreateOrders < ActiveRecord::Migration[6.0]
@@ -1,3 +1,3 @@
1
1
  module Stateful
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stateful.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran