Created
July 14, 2020 12:45
-
-
Save kainew/bd655b16ffd9cb3037dbf3e5b835e65c to your computer and use it in GitHub Desktop.
Idealization codes for Donato's workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
State | |
uid | |
name | |
possible_next_states | |
default_error_state | |
process [ | |
update_status, | |
call_whatever, | |
... | |
] | |
State.possible_next_states.map(&:next_state) | |
State.flow(current_status, next_desired_state) { | |
can_change = current_status.possible_next_states.include(next_desired_state) | |
State.process.each.call(current_status, can_change, next_desired_state) | |
return can_change | |
} | |
update_status(current_status, can_change, next_desired_state) { | |
next_state = can_change? next_desired_state : current_status.default_error_state | |
State.update(current_state: next_desired_state) | |
workflow_log_create(current_state, next_desired_state, current_status) | |
} | |
workflow_log_create(current_state, next_desired_state, current_status){ | |
WorkflowLog.create(current_state: current_state, next_desired_state: next_desired_state, current_status) | |
} | |
call_whatever(state_object, can_change, next_desired_state) { ... } | |
------------- | |
Model Before Create/Update... | |
check_workflow_actions | |
Do workflow changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment