Exception: LiteState::TransitionError

Inherits:
Error
  • Object
show all
Defined in:
lib/lite_state.rb

Overview

Raised when an invalid transition is attempted

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record:, to:, from:, event:) ⇒ TransitionError

Returns a new instance of TransitionError.

Parameters:

  • record (ActiveRecord::Base)

    the record being transitioned

  • to (Symbol)

    the target state

  • from (Symbol)

    the current state

  • event (Symbol)

    the transition event



63
64
65
66
67
68
69
# File 'lib/lite_state.rb', line 63

def initialize(record:, to:, from:, event:)
  @record = record
  @to = to
  @from = from
  @event = event
  super("Invalid transition: #{record.class} ##{record.id} from #{from.inspect} -> #{to.inspect} on #{event}")
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



57
58
59
# File 'lib/lite_state.rb', line 57

def event
  @event
end

#fromObject (readonly)

Returns the value of attribute from.



57
58
59
# File 'lib/lite_state.rb', line 57

def from
  @from
end

#recordObject (readonly)

Returns the value of attribute record.



57
58
59
# File 'lib/lite_state.rb', line 57

def record
  @record
end

#toObject (readonly)

Returns the value of attribute to.



57
58
59
# File 'lib/lite_state.rb', line 57

def to
  @to
end