linear_work_flow 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +26 -0
- data/lib/linear_work_flow/version.rb +1 -1
- data/lib/linear_work_flow/work_flow.rb +16 -0
- metadata +2 -3
- data/linear_work_flow-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b78df7b25c35a44cd5d7ffc564a66987dac0ad6
|
4
|
+
data.tar.gz: f5ea69804b59133f401afdb4375e5af07e8e5407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e2a6cbf50ab336a69957c262e32246b1aa6fcafef54fefd3ee4e1af781cb1a7960b38cd9786d9c9dd89a2cf6c8ab166d02b7774c02453835dd7fafa94404ebd
|
7
|
+
data.tar.gz: 9c90a368283b5ac8099abd22e5704dc67a12b7eb22dfa225e81ab69bfcc82e3d9683c2f9793eac5c7a44294e3092cc21774255b97a68e07d8028613836029354
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,32 @@ work_flow.first? == true
|
|
74
74
|
work_flow.last? == false
|
75
75
|
```
|
76
76
|
|
77
|
+
### Check permissible states
|
78
|
+
|
79
|
+
At any intermediate state the state can go back, go forward, or remain the same.
|
80
|
+
The `permissible_states` method returns the states that match these actions.
|
81
|
+
|
82
|
+
If the state is at the first state there cannot be a back transition, so in
|
83
|
+
this case `permissible_states` returns the current state and the go forward state.
|
84
|
+
Similarly, as the state cannot go forward from the last state, `permissible_states`
|
85
|
+
returns the go back state and the current state when the last state is the
|
86
|
+
current state.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
work_flow = WorkFlow.new
|
90
|
+
work_flow.state == :one
|
91
|
+
work_flow.permissible_states == [:one, :two]
|
92
|
+
work_flow.forward!
|
93
|
+
work_flow.state == :two
|
94
|
+
work_flow.permissible_states == [:one, :two, :three]
|
95
|
+
work_flow.forward!
|
96
|
+
work_flow.state == :three
|
97
|
+
work_flow.permissible_states == [:two, :three, :four]
|
98
|
+
work_flow.forward!
|
99
|
+
work_flow.state == :four
|
100
|
+
work_flow.permissible_states == [:three, :four]
|
101
|
+
```
|
102
|
+
|
77
103
|
### Initiate at a particular state
|
78
104
|
|
79
105
|
A work flow can be initiate at a particular state.
|
@@ -40,6 +40,22 @@ module LinearWorkFlow
|
|
40
40
|
index == 0
|
41
41
|
end
|
42
42
|
|
43
|
+
def permissible_states
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
|
47
|
+
def forward_state
|
48
|
+
states[index + 1] unless last?
|
49
|
+
end
|
50
|
+
|
51
|
+
def back_state
|
52
|
+
states[index - 1] unless first?
|
53
|
+
end
|
54
|
+
|
55
|
+
def permissible_states
|
56
|
+
[back_state, state, forward_state].compact
|
57
|
+
end
|
58
|
+
|
43
59
|
def can?(action)
|
44
60
|
!!restore_after do
|
45
61
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linear_work_flow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Nichols
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,7 +72,6 @@ files:
|
|
72
72
|
- lib/linear_work_flow/errors.rb
|
73
73
|
- lib/linear_work_flow/version.rb
|
74
74
|
- lib/linear_work_flow/work_flow.rb
|
75
|
-
- linear_work_flow-0.1.0.gem
|
76
75
|
- linear_work_flow.gemspec
|
77
76
|
homepage: https://github.com/reggieb/linear_work_flow
|
78
77
|
licenses:
|
data/linear_work_flow-0.1.0.gem
DELETED
Binary file
|