Exception: Statecraft::InvalidTransition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record:, from:, requested:, allowed:, message: nil) ⇒ InvalidTransition

Returns a new instance of InvalidTransition.



26
27
28
29
30
31
32
33
34
35
# File 'lib/statecraft/errors.rb', line 26

def initialize(record:, from:, requested:, allowed:, message: nil)
  @record = record
  @from = from
  @requested = requested
  @allowed = allowed
  default_message = "transition #{from} -> #{requested} is not declared for " \
                    "#{record.class.name}; allowed from #{from}: " \
                    "#{allowed.empty? ? "none" : allowed.join(", ")}"
  super(message || default_message)
end

Instance Attribute Details

#allowedObject (readonly)

Returns the value of attribute allowed.



24
25
26
# File 'lib/statecraft/errors.rb', line 24

def allowed
  @allowed
end

#fromObject (readonly)

Returns the value of attribute from.



24
25
26
# File 'lib/statecraft/errors.rb', line 24

def from
  @from
end

#recordObject (readonly)

Returns the value of attribute record.



24
25
26
# File 'lib/statecraft/errors.rb', line 24

def record
  @record
end

#requestedObject (readonly)

Returns the value of attribute requested.



24
25
26
# File 'lib/statecraft/errors.rb', line 24

def requested
  @requested
end