The session handling logic is encapsulated in the SessionHandler module extension which is added to the ActionFlow::Base class eval at the plugin initialization.
The session handler has the following responsibilities.
To store values relevant to the current flow state, simply interact with the state attribute.
def some_step_definition state[ :key ] = :lets_put_something_in end
See the state page for more details.
Each flow’s session data is structured in the user’s session hash as follows.
----> User session hash
|
-----> flow data
| |
| -----> state data
| |
| -----> state data
| |
| -----> state data
| |
| -----> timestamp
|
-----> flow data
|
-----> state data
|
-----> state data
|
-----> state data
|
-----> timestamp
Therefore, each time a new flow is launched (which means no flow execution key was supplied), a new flow session data placeholder is created. We call it a state. After that, once the user submits a flow execution key, the correct state is fetched and written from the correct session state placeholder.
Here’s an example of the session data structure with correct values. The unique keys used here are not representative of a real world situation, since the numbers are random.
----> User session hash
|
-----> flow_data-00000001
| |
| -----> 00000(...)001
| | |
| | ----> last_step_name
| |
| -----> 00000(...)002
| | |
| | ----> last_step_name
| |
| -----> 00000(...)003
| | |
| | ----> last_step_name
| |
| -----> timestamp => 20070101 12:01:01.001
|
-----> flow_data-00000002
|
-----> 00000(...)001
| |
| ----> last_step_name
|
-----> 00000(...)002
| |
| ----> last_step_name
|
-----> 00000(...)003
| |
| ----> last_step_name
|
-----> timestamp => 20070101 13:01:01.001
~~DISCUSSION~~
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.