bstard 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +17 -1
- data/lib/bstard/fsm.rb +1 -1
- data/lib/bstard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjUzNDM2MWNmNTA1MjM5MTE5MDJhYTdlNjU2NWVhYTNmMWY0MGI5ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmE2MGQwY2M1YTVmYzJkMTAwY2ZhNWM3ZmUyYzVjMzNmODNhYmJhZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDhiZDcxNGU4MDgyNTgxN2YxYTViOWEzYjkwZWU0YjBmNjI1YmFlYWZmMmI0
|
10
|
+
N2M1MWU0ZWVjYTE5MDQ5ZGI3ZjA5NzlhMTU1NjcwNjFmZmIyNDIzZDhmN2Rh
|
11
|
+
ZTQ5YmQ3ZDk2ZTU5MTBjZWI3YjE3MjFmMjE5N2M4ZTcxYjU3NTk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDZjODEwNTg1NGJkN2U1ZGE1MDAxOGUwODI2ZTJiMDc0MzY1MTVkNjgyYzIy
|
14
|
+
NWFmZjVlNGYwMWEyYThlZjVkMWRmNmMxMmI2Yzg0NmViYmZiOGVlNjBmZjM1
|
15
|
+
ZmUyMmIzNDkxNDVlMzEwYTU4YmVkODE5NDIzOWNjYmY4NDg1YWM=
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ This defines a state machine that:
|
|
44
44
|
Pretty simple huh?
|
45
45
|
|
46
46
|
### Initial State
|
47
|
-
Set the initial state of the machine with `initial`. If no initial state is set a default state `:uninitialized` is used.
|
47
|
+
Set the initial state of the machine with `initial`. If no initial state is set a default state `:uninitialized` is used. As a safeguard `initial` will ignore `nil` or empty string values.
|
48
48
|
|
49
49
|
### Querying the State
|
50
50
|
|
@@ -79,6 +79,22 @@ Helper methods are dynamically generated to enable querying whether an event can
|
|
79
79
|
#=> false
|
80
80
|
```
|
81
81
|
|
82
|
+
### Defining Events
|
83
|
+
|
84
|
+
Events are defined by supplying an event name followed by one or more state transition declarations. Each state transition declaration is just a hash key value pair. The key represents the starting state and the value the ending state.
|
85
|
+
|
86
|
+
``` ruby
|
87
|
+
machine = Bstard.define do |fsm|
|
88
|
+
fsm.initial :new
|
89
|
+
fsm.event :save, :new => :draft
|
90
|
+
fsm.event :approve, :draft => :approved
|
91
|
+
fsm.event :publish, :approved => :published
|
92
|
+
fsm.event :delete, :draft => :deleted, :approved => :deleted
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
I find the spear `=>` Hash syntax style works best for me in describing the intent of the definition.
|
97
|
+
|
82
98
|
### Triggering Events
|
83
99
|
|
84
100
|
Trigger events by sending a message using the event name suffixed with an exclamation mark.
|
data/lib/bstard/fsm.rb
CHANGED
data/lib/bstard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bstard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Headford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|