Rails 앱에서 geekq의 Workflow gem 을 사용 합니다. 이제 워크 플로가 다르게 종료 될 수있는 상황을 처리해야합니다. 다음은 예입니다.
A의 정상적인 흐름이 purchase order
될 수있다 issue PO=>receive delivery at front desk=>receive into production warehouse
. 생산 품목 및 비 생산 품목의 경우 두 가지 워크 플로우가 있습니다.
production item#: issue PO=>receive delivery at front desk=>receive into production warehouse
non-production item#: issue PO=>receive delivery at front desk
우리의 질문은 다음과 같습니다.
geekq / workflow spec 에서 여기에 솔루션을 제공하는 조건부 이벤트 전환에 대한 섹션이 있습니다.
Conditions are procs or lambdas added to events, like so:
state :off
event :turn_on, :transition_to => :on,
:if => proc { |device| device.battery_level > 0 }
event :turn_on, :transition_to => :low_battery,
:if => proc { |device| device.battery_level > 10 }
end
When calling a device.can_<fire_event>? check, or attempting a device.<event>!, each event is checked in turn:
With no :if check, proceed as usual.
If an :if check is present, proceed if it evaluates to true, or drop to the next event.
If you've run out of events to check (eg. battery_level == 0), then the transition isn't possible.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다