Exception: AASM::InvalidTransition

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/aasm/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, event_name, state_machine_name, failures = []) ⇒ InvalidTransition

Returns a new instance of InvalidTransition.



8
9
10
11
12
# File 'lib/aasm/errors.rb', line 8

def initialize(object, event_name, state_machine_name, failures = [])
  @object, @event_name, @originating_state, @failures = object, event_name, object.aasm(state_machine_name).current_state, failures
  @state_machine_name = state_machine_name
  super("Event '#{event_name}' cannot transition from '#{originating_state}'.#{reasoning}")
end

Instance Attribute Details

#event_nameObject (readonly)

Returns the value of attribute event_name.



6
7
8
# File 'lib/aasm/errors.rb', line 6

def event_name
  @event_name
end

#failuresObject (readonly)

Returns the value of attribute failures.



6
7
8
# File 'lib/aasm/errors.rb', line 6

def failures
  @failures
end

#objectObject (readonly)

Returns the value of attribute object.



6
7
8
# File 'lib/aasm/errors.rb', line 6

def object
  @object
end

#originating_stateObject (readonly)

Returns the value of attribute originating_state.



6
7
8
# File 'lib/aasm/errors.rb', line 6

def originating_state
  @originating_state
end

#state_machine_nameObject (readonly)

Returns the value of attribute state_machine_name.



6
7
8
# File 'lib/aasm/errors.rb', line 6

def state_machine_name
  @state_machine_name
end

Instance Method Details

#reasoningObject



14
15
16
# File 'lib/aasm/errors.rb', line 14

def reasoning
  " Failed callback(s): #{failures}." unless failures.empty?
end