Closed tonyvince closed 3 years ago
Maybe you can add the if condition in method that returns transitions. i.e.
def transitions
transitions = [
{ :awaiting_quote_acceptance => :awaiting_final_invoice, :on => :accept_quote },
{ :awaiting_quote_acceptance => :awaiting_quote, :on => :decline_quote },
{ :awaiting_order_acceptance => :order_placed, :on => :accept_order }
]
transitions << { :awaiting_quote => :awaiting_quote_acceptance, :on => :submit_quote } if line_item_details_complete?
transitions << { :awaiting_final_invoice => :awaiting_order_acceptance, :on => :submit_final_invoice } if attachment?
transitions
end
I had a previous state machine like the following
as you can see 2 of the state changes are dependent on
line_item_details_complete?
andattachment?
methods in my modelNow I am trying to implement the same state machine using dynamic state definitions
Now how do I use the same conditional state changes in this approach? Where should I add the
if:
option? Thank you