2011-11-26 17:55:50 +00:00
|
|
|
module AASM
|
2015-03-02 04:08:45 +00:00
|
|
|
|
2015-08-05 10:00:22 +00:00
|
|
|
class UnknownStateMachineError < RuntimeError; end
|
|
|
|
|
2015-03-02 04:08:45 +00:00
|
|
|
class InvalidTransition < RuntimeError
|
2019-01-02 22:26:39 +00:00
|
|
|
attr_reader :object, :event_name, :originating_state, :failures, :state_machine_name
|
2015-05-13 10:12:59 +00:00
|
|
|
|
2015-10-22 02:38:07 +00:00
|
|
|
def initialize(object, event_name, state_machine_name, failures = [])
|
2016-03-15 19:54:35 +00:00
|
|
|
@object, @event_name, @originating_state, @failures = object, event_name, object.aasm(state_machine_name).current_state, failures
|
2019-01-02 22:26:39 +00:00
|
|
|
@state_machine_name = state_machine_name
|
2017-08-16 10:47:24 +00:00
|
|
|
super("Event '#{event_name}' cannot transition from '#{originating_state}'.#{reasoning}")
|
2015-10-22 02:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reasoning
|
2017-08-16 10:47:24 +00:00
|
|
|
" Failed callback(s): #{failures}." unless failures.empty?
|
2015-03-02 04:08:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-26 17:55:50 +00:00
|
|
|
class UndefinedState < RuntimeError; end
|
2022-07-27 09:58:17 +00:00
|
|
|
class UndefinedEvent < UndefinedState; end
|
2014-05-18 12:21:35 +00:00
|
|
|
class NoDirectAssignmentError < RuntimeError; end
|
2011-11-26 17:55:50 +00:00
|
|
|
end
|