Sha256: 94dea8a816c4e6297a43610ac1795bd16eb6c45954303fbd7d3ef6f684c0522a

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

module AASM

  class UnknownStateMachineError < RuntimeError; end

  class InvalidTransition < RuntimeError
    attr_reader :object, :event_name, :state_machine_name, :failures

    def initialize(object, event_name, state_machine_name, failures = [])
      @object, @event_name, @state_machine_name, @failures = object, event_name, state_machine_name, failures
    end

    def message
      "Event '#{event_name}' cannot transition from '#{object.aasm(state_machine_name).current_state}'. #{reasoning}"
    end

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

  class UndefinedState < RuntimeError; end
  class NoDirectAssignmentError < RuntimeError; end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aasm-4.9.0 lib/aasm/errors.rb
aasm-4.8.0 lib/aasm/errors.rb