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
We wanted to use this state machine as only in memory for models whose state history we were not as concerned with. Without specifying a transition_class, transitions are stored to memory, but the current_state, transition_to methods etc. look into the state_machine.history to determine the current_state or whether a transition can be made. This history doesn't exist without the transition_class so the state machine was not reading from memory where the transitions were being stored.
As a fix, our state_machine method looked like this:
def state_machine
@_state_machine ||= begin
@state_machine = OrderStateMachine.new(self)
if state
@state_machine.history << Statesman::Adapters::MemoryTransition.new(state, 0)
end
@state_machine
end
end
This was used in multiple places for us, so it could be useful for others as well, who want to save their transitions in memory.
The text was updated successfully, but these errors were encountered:
We wanted to use this state machine as only in memory for models whose state history we were not as concerned with. Without specifying a
transition_class
, transitions are stored to memory, but thecurrent_state
,transition_to
methods etc. look into thestate_machine.history
to determine thecurrent_state
or whether a transition can be made. This history doesn't exist without the transition_class so the state machine was not reading from memory where the transitions were being stored.As a fix, our state_machine method looked like this:
This was used in multiple places for us, so it could be useful for others as well, who want to save their transitions in memory.
The text was updated successfully, but these errors were encountered: