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
This is for the benefit of implementations that may need to persist the
state to some storage.
Also fix the implementation of the workflow specific role.
Copy file name to clipboardexpand all lines: Documentation.md
+25-1
Original file line number
Diff line number
Diff line change
@@ -393,7 +393,9 @@ The same rules for execution based on the signature and the object to which the
393
393
role Tinky::Object
394
394
------------------
395
395
396
-
This is a role that should should be applied to any application object that is to have a state managed by [Tinky::Workflow](Tinky::Workflow), it provides the mechanisms for transition application and allows the transitions to be validated by the mechanisms described above for [Tinky::State](Tinky::State) and [Tinky::Transition](Tinky::Transition)
396
+
This is a role that should should be applied to any application object that is to have a state managed by [Tinky::Workflow](Tinky::Workflow), it provides the mechanisms for transition application and allows the transitions to be validated by the mechanisms described above for [Tinky::State](Tinky::State) and [Tinky::Transition](Tinky::Transition).
397
+
398
+
There are also method traits to define methods that will be called before and after the application of the workflow to the object, and before and after the application of a transition to the object.
397
399
398
400
### method state
399
401
@@ -440,6 +442,28 @@ This returns the transition that would place the object in the supplied state fr
440
442
441
443
Used to smart match the object against either a State (returns True if the state matches the current state of the object,) or a Transition (returns True if the `from` state matches the current state of the object.)
442
444
445
+
### trait before-apply-workflow
446
+
447
+
This trait can be applied to a method that will be called within the `apply-workflow` immediately after the application has been validated and before anything else occurs (primarily the setting of an initial state state if any.) The method will be called with the Workflow object as an argument.
448
+
449
+
This is primarily for the benefit of implementations that may want to, for instance, retrieve the object state from some storage before setting up the rest of the workflow.
450
+
451
+
### trait after-apply-workflow
452
+
453
+
This trait can be applied to a method that will be called within the `apply-workflow` immediately before the Workflow's `applied` method is called with the object, that is the initial state will have been set and other changes made. The method will be called with the Workflow object as an argument.
454
+
455
+
This may be helpful, for example, if one wanted to persist the initial state to some storage.
456
+
457
+
### trait before-apply-transition
458
+
459
+
This trait can be applied to a method that will be called within the `apply-transition` immediately after the validation has been done and before the state is actually changed. The method will be called with the Transition object as the argument.
460
+
461
+
### trait after-apply-transition
462
+
463
+
This trait can be applied to a method that will be called within the `apply-transition` after the state of the object has been changed and immediately before the object is passed to the transition's `applied` method. The method will be called with the Transition object as the argument.
464
+
465
+
This might be used, for example, to persist the change of state of the object to some storage.
0 commit comments