Exception: StateMachine::InvalidTransition
- Inherits:
-
Error
- Object
- StandardError
- Error
- StateMachine::InvalidTransition
- Defined in:
- lib/state_machine/transition.rb
Overview
An invalid transition was attempted
Instance Attribute Summary (collapse)
-
- (Object) from
readonly
The current state value for the machine.
-
- (Object) machine
readonly
The machine attempting to be transitioned.
Attributes inherited from Error
Instance Method Summary (collapse)
-
- (Object) event
The event that triggered the failed transition.
-
- (Object) from_name
The name for the current state.
-
- (InvalidTransition) initialize(object, machine, event)
constructor
:nodoc:.
-
- (Object) qualified_event
The fully-qualified name of the event that triggered the failed transition.
-
- (Object) qualified_from_name
The fully-qualified name for the current state.
Constructor Details
- (InvalidTransition) initialize(object, machine, event)
:nodoc:
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/state_machine/transition.rb', line 13 def initialize(object, machine, event) #:nodoc: @machine = machine @from_state = machine.states.match!(object) @from = machine.read(object, :state) @event = machine.events.fetch(event) errors = machine.errors_for(object) = "Cannot transition #{machine.name} via :#{self.event} from #{from_name.inspect}" << " (Reason(s): #{errors})" unless errors.empty? super(object, ) end |
Instance Attribute Details
- (Object) from (readonly)
The current state value for the machine
11 12 13 |
# File 'lib/state_machine/transition.rb', line 11 def from @from end |
- (Object) machine (readonly)
The machine attempting to be transitioned
8 9 10 |
# File 'lib/state_machine/transition.rb', line 8 def machine @machine end |
Instance Method Details
- (Object) event
The event that triggered the failed transition
26 27 28 |
# File 'lib/state_machine/transition.rb', line 26 def event @event.name end |
- (Object) from_name
The name for the current state
36 37 38 |
# File 'lib/state_machine/transition.rb', line 36 def from_name @from_state.name end |
- (Object) qualified_event
The fully-qualified name of the event that triggered the failed transition
31 32 33 |
# File 'lib/state_machine/transition.rb', line 31 def qualified_event @event.qualified_name end |
- (Object) qualified_from_name
The fully-qualified name for the current state
41 42 43 |
# File 'lib/state_machine/transition.rb', line 41 def qualified_from_name @from_state.qualified_name end |