You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-1Lines changed: 51 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ decision. When called, the decision macro will invoke this method, then
28
28
act according to the truthiness of the response returned - invoking the
29
29
code in its `yes` block for true, and `no` block for false.
30
30
31
-
To accomodate interruptions to the decision tree, perhaps at locations where
31
+
To accommodate interruptions to the decision tree, perhaps at locations where
32
32
user input is required, the `entry` macro can be used to define new entry
33
33
points. This macro takes the name of the entry point, and can be invoked by
34
34
calling this method from outside the workflow class.
@@ -90,6 +90,56 @@ class Change < ActiveRecord::Base
90
90
end
91
91
```
92
92
93
+
##Displaying the Workflow
94
+
Human readable display of workflow steps can be achieved by using `DecisionTree::Step#display`.
95
+
E.g.
96
+
97
+
```ruby
98
+
- workflow.steps.each do |step|
99
+
= step.display
100
+
```
101
+
102
+
The value returned by this will either be one set explicitly in the translations, or one implicitly derived from the step name.
103
+
104
+
105
+
### Explicit Display Values
106
+
Human readable translations are defined under `workflow_steps`.
107
+
108
+
E.g.:
109
+
110
+
workflow_steps:
111
+
entry_point:
112
+
__start_workflow: 'Decision Workflow Started'
113
+
reviewed_by_etd!: 'ETD has reviewed the provided evidence'
114
+
idempotent_call:
115
+
mark_for_review!: 'Waiting on ETD to review evidence'
116
+
approval_only_required_from_initiator?:
117
+
'yes': 'Approval is only required from the initiator'
118
+
'no': 'This change must be approved by more than the initiator'
119
+
120
+
Any entry point into the workflow is defined under `entry_point`, including the initial one that is automatically created by the gem (`__start_workflow`).
121
+
Any idempotent calls (identified by a trailing `!`) are defined under `idempotent_call`.
122
+
123
+
Any regular steps (with a yes/no outcome) are defined directly under `workflow_steps`, and contain values for both 'yes', and 'no'. Note that these keys should be defined as strings (explicitly wrapped in quotes), otherwise YAML helpfully converts these to booleans, which will not be matched when looking for a description.
124
+
125
+
### Implicit Display Values
126
+
Semi-friendly display values are still returned if no translation has been defined.
127
+
For a regular step, the question will be rendered, followed by the answer.
128
+
129
+
```
130
+
# method name: is_contract_full_time?
131
+
# answer is 'NO'
132
+
step.display # => Is contract full time? - No
133
+
134
+
```
135
+
136
+
Entry points and idempotent calls are also slightly humanised.
137
+
138
+
```
139
+
:reviewed_by_etd! # => Reviewed by etd!
140
+
```
141
+
142
+
93
143
## Contributing
94
144
95
145
1. Fork it ( http://github.com/jobready/decision_tree/fork )
0 commit comments