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
When configuring a transition you can either pass a single state as a string or symbol as the :to argument, or alternatively you can configure multiple transitions by passing an array of strings or symbols.
However, it seems that transition is the only method which accepts arrays when configuring a state machine.
Why do none of the others, such as the before_transition, after_transition callbacks or the guards accept an array of states? Is it a conscious design decision or just something you've not implemented through lack of requirement on your part?
For example, I have a payment system which accepts online payments by cards, or postal payments by cheque. It has a simple state machine:
This uses my modified version of statesman as detailed in pull request #78 which allows the state machine to decide which state to transition to when the :transaction_processed event is triggered based on the metadata passed in from my payment service object.
As you can see, the completion state for card payments is :card_payment_captured, whilst the completion state for postal orders is :cheque_received. However, in both of these cases, once that state is reached, the associated order items need to be marked as paid so that they can be processed.
I would like to be able to use the following syntax when configuring this sort of post-transition processing within a state machine:
With the existing code I would have to write two separate after_transition callbacks with identical contents, which just doesn't feel right. Before you suggest that I move to a state machine with a single :paid end-state, I'd rather keep the two payment types segregated.
What do you think?
The text was updated successfully, but these errors were encountered:
When configuring a
transition
you can either pass a single state as a string or symbol as the:to
argument, or alternatively you can configure multiple transitions by passing an array of strings or symbols.However, it seems that
transition
is the only method which accepts arrays when configuring a state machine.Why do none of the others, such as the
before_transition
,after_transition
callbacks or the guards accept an array of states? Is it a conscious design decision or just something you've not implemented through lack of requirement on your part?For example, I have a payment system which accepts online payments by cards, or postal payments by cheque. It has a simple state machine:
This uses my modified version of
statesman
as detailed in pull request #78 which allows the state machine to decide which state to transition to when the:transaction_processed
event is triggered based on the metadata passed in from my payment service object.As you can see, the completion state for card payments is
:card_payment_captured
, whilst the completion state for postal orders is:cheque_received
. However, in both of these cases, once that state is reached, the associated order items need to be marked as paid so that they can be processed.I would like to be able to use the following syntax when configuring this sort of post-transition processing within a state machine:
With the existing code I would have to write two separate
after_transition
callbacks with identical contents, which just doesn't feel right. Before you suggest that I move to a state machine with a single:paid
end-state, I'd rather keep the two payment types segregated.What do you think?
The text was updated successfully, but these errors were encountered: