Closed davidjbeveridge closed 8 years ago
The biggest issue here and why the two methods even exist is because passed
and failed
are user supplied when subclassing Guard
. Since we don't know what they are doing we wanted a "safe" way to just check without potentially "doing" anything. In an ideal world a guard would never change things and you could just check it any time you want but we don't live in an ideal world.
All of that being said, there is nothing that says the logic to add messages into failure_messages
has to happen in the failed
method. I believe that's how some guards have been built, but all the failed
method is for is a place to put stuff that should happen when a guard fails, like say log it out or take some action or whatever. If you have your actual check as defined in will_allow?
actually fill failure_messages
then it works just fine as is.
Fair enough.
StateMachine#can_transition? now uses Guard#allowed? instead of Guard#will_allow?
@alexpeachey I could really use
failure_messages
when checkingcan_transition?
. Thoughts?