@@ -23,22 +23,24 @@ var validateRequest = function(req, cb) {
23
23
}
24
24
var initialState = body . initialState
25
25
26
- for ( var state in states ) {
27
-
26
+ for ( var stateName in states ) {
27
+
28
+ var state = states [ stateName ]
29
+
28
30
if ( state . hasOwnProperty ( 'transitions' ) && ( state . transitions instanceof Array ) ) {
29
31
30
- for ( var tid in transitions ) {
32
+ for ( var tid in state . transitions ) {
31
33
32
- var transition = transitions [ tid ]
34
+ var transition = state . transitions [ tid ]
33
35
34
- // Ensure transition has 'input ' property present
35
- if ( ! transition . hasOwnProperty ( 'input ' ) ) {
36
- cb ( { code : 400 , message : 'Missing transition property \'input \'' } )
36
+ // Ensure transition has 'match ' property present
37
+ if ( ! transition . hasOwnProperty ( 'match ' ) ) {
38
+ cb ( { code : 400 , message : 'Missing transition property \'match \'' } )
37
39
}
38
40
39
- // Ensure transition has 'newState ' property present
40
- if ( ! transition . hasOwnProperty ( 'newState ' ) ) {
41
- cb ( { code : 400 , message : 'Missing transition property \'newState \'' } )
41
+ // Ensure transition has 'nextState ' property present
42
+ if ( ! transition . hasOwnProperty ( 'nextState ' ) ) {
43
+ cb ( { code : 400 , message : 'Missing transition property \'nextState \'' } )
42
44
}
43
45
44
46
} // END for - transitions
@@ -57,12 +59,12 @@ var validateRequest = function(req, cb) {
57
59
for ( var tid in state . transitions ) {
58
60
59
61
var transition = state . transitions [ tid ]
60
- var input = transition . input
61
- var transitionState = transition . newState
62
+ var match = transition . match
63
+ var transitionState = transition . nextState
62
64
63
65
// Ensure transition state is one of the defined states
64
66
if ( ! states . hasOwnProperty ( transitionState ) ) {
65
- cb ( { code : 400 , message : 'Transition state for state \'' + state + '\' and input \'' + input + '\' not found' } )
67
+ cb ( { code : 400 , message : 'Transition state for state \'' + state + '\' and match \'' + match + '\' not found' } )
66
68
}
67
69
68
70
} // END for - transitions
@@ -90,7 +92,6 @@ var persistInitialState = function(stateMachine, dbStateMachine, cb) {
90
92
dbStateMachine . current_state_id = state . id
91
93
dbStateMachine . save ( )
92
94
. success ( function ( dbsm ) {
93
- console . log ( dbsm . current_state_id )
94
95
cb ( null , stateMachine , dbsm )
95
96
} )
96
97
. error ( cb )
@@ -144,7 +145,7 @@ var persistTransitions = function(stateMachine, dbStateMachine, cb) {
144
145
145
146
models . transition . create ( {
146
147
state_id : dbState . id ,
147
- input : transition . input ,
148
+ match : transition . match ,
148
149
next_state_id : dbNextState . id
149
150
} )
150
151
. success ( function ( t ) { callback ( ) } )
0 commit comments