examples/advanced.rb in state_shifter-0.8.1 vs examples/advanced.rb in state_shifter-1.0.3
- old
+ new
@@ -1,37 +1,44 @@
class Advanced
include StateShifter::Definition
- ###
+ ###
state_machine do
state :initialized do
-
event :start_date_changed, :call => :handle_start_date_changed
event :forced_start => :running
event :start_date_reached => :running, :if => :start_date_reached?
event :abort_initialized_contest => :finalized
+ event :event_associated => :preparing
end
+ state :preparing do
+ on_entry :prepare
+
+ event :all_done => :running
+ end
+
state :running do
on_entry do |previous_state, trigger_event|
running_entry previous_state, trigger_event
end
- event :abort_running_contest => :notify_stakeholders
+ event :abort_running_contest => :notify_stakeholders
event :changed_properties
event :keep_users_engaged
event :deadline_reached => :notify_organizers, :if => :entries_deadline_reached?
event :spots_filled => :notify_organizers, :if => :spots_filled?
event :deadline_reached_without_approvals => :notify_pending_users, :if => :entries_deadline_reached_without_approvals?
event :deadline_reached_without_entries => :finalized, :if => :entries_deadline_reached_without_entries?
end
state :notify_organizers do
on_entry :send_notification_to_organizers
+
event :organizers_notified => :awaiting_organizer_reply
end
state :awaiting_organizer_reply do
event :organizer_confirmation_missing => :notify_stakeholders, :if => :organizer_confirmation_deadline_reached?
@@ -40,10 +47,11 @@
event :organizer_has_more_tickets => :running
end
state :notify_stakeholders do
on_entry :send_notification, :stakeholders, :organizers
+
event :stakeholders_notified => :cancelled
end
state :cancelled
@@ -77,9 +85,13 @@
benchmark from, to, trigger_event, duration
end
end
###
+
+ def prepare
+ all_done!
+ end
def send_notification to
#
end