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
|
2015-10-22 02:38:07 +00:00
|
|
|
attr_reader :object, :event_name, :state_machine_name, :failures
|
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 = [])
|
|
|
|
@object, @event_name, @state_machine_name, @failures = object, event_name, state_machine_name, failures
|
2015-03-02 04:08:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
2016-01-10 23:13:38 +00:00
|
|
|
"Event '#{event_name}' cannot transition from '#{object.aasm(state_machine_name).current_state}'. #{reasoning}"
|
2015-10-22 02:38:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reasoning
|
2016-01-10 23:13:38 +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
|
2014-05-18 12:21:35 +00:00
|
|
|
class NoDirectAssignmentError < RuntimeError; end
|
2011-11-26 17:55:50 +00:00
|
|
|
end
|