gocardless / statesman

A statesmanlike state machine library.
https://gocardless.com/blog/statesman/
MIT License
1.78k stars 163 forks source link

A tip from me #404

Closed mehmetaydogduu closed 6 months ago

mehmetaydogduu commented 4 years ago

If anyone wants to access shipped?, purchased? like methods from model directly. I have a solution.

Store current state on the model. Define an enum like this. enum state: PaymentTransactionStateMachine.states.collect { |s| [s,s]}.to_h

Useful when you need checks like if @transaction.success?

This is more fast and short way because it doesn't query anything if you already have your model in memory.