def after_failure(*args, &block)
      options = (args.last.is_a?(Hash) ? args.pop : {})
      options[:do] = args if args.any?
      assert_valid_keys(options, :on, :do, :if, :unless)
      
      add_callback(:failure, options, &block)
    end
def after_failure(*args, &block)
      options = (args.last.is_a?(Hash) ? args.pop : {})
      options[:do] = args if args.any?
      assert_valid_keys(options, :on, :do, :if, :unless)
      
      add_callback(:failure, options, &block)
    end
Creates a callback that will be invoked *after* a transition failures to
 be performed so long as the given requirements match the transition.

 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.

 = The callback

 Failure callbacks get invoked whenever an event fails to execute.  This
 can happen when no transition is available, a +before+ callback halts
 execution, or the action associated with this machine fails to succeed.
 In any of these cases, any failure callback that matches the attempted
 transition will be run.

 For example,

   class Vehicle
     state_machine do
       after_failure do |vehicle, transition|
         logger.error "vehicle #{vehicle} failed to transition on #{transition.event}"
       end

       after_failure :on => :ignite, :do => :log_ignition_failure

       ...
     end
   end