Method: StateMachine::Integrations::DataMapper::Observer#after_transition_failure

Defined in:
lib/state_machine/integrations/data_mapper/observer.rb

#after_transition_failure(*args, &block) ⇒ Object

Creates a callback that will be invoked after a transition failures to be performed so long as the given requirements match the transition.

Example

class Vehicle
  include DataMapper::Resource

  property :id, Serial
  property :state, :String

  state_machine :initial => :parked do
    event :ignite do
      transition :parked => :idling
    end
  end
end

class VehicleObserver
  after_transition_failure do |transition|
    # log failure
  end

  after_transition_failure :on => :ignite do
    # log failure
  end
end

See before_transition for a description of the possible configurations for defining callbacks. Note however that you cannot define the state requirements in these callbacks. You may only define event requirements.



174
175
176
# File 'lib/state_machine/integrations/data_mapper/observer.rb', line 174

def after_transition_failure(*args, &block)
  add_transition_callback(:after_failure, *args, &block)
end