Class: StateMachines::Sequel::FailedTransition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, event) ⇒ FailedTransition

Returns a new instance of FailedTransition.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/state_machines/sequel.rb', line 12

def initialize(obj, event)
  @event = event
  @object = obj
  msg = "#{obj.class}[#{obj.id}] failed to transition on #{event}"
  if obj.respond_to?(:audit_logs) && !obj.audit_logs.empty?
    @audit_log = obj.audit_logs.max_by(&:id)
    msg += ": #{@audit_log.full_message}"
    msg = msg.gsub("\n", ", ").strip
  end
  super(obj, msg)
end

Instance Attribute Details

#audit_logObject (readonly)

Returns the value of attribute audit_log.



10
11
12
# File 'lib/state_machines/sequel.rb', line 10

def audit_log
  @audit_log
end

#eventObject (readonly)

Returns the value of attribute event.



10
11
12
# File 'lib/state_machines/sequel.rb', line 10

def event
  @event
end

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/state_machines/sequel.rb', line 10

def object
  @object
end