def guarded_execute(event_type, event_trigger_value)
      @state_machine.raise_outside_initial_queue

      return if terminating?

      if @transition_map[event_type].nil? ||
         @transition_map[event_type][event_trigger_value].nil?
        raise ArgumentError,
          "No registered transition found "\
          "for event #{event_type}:#{event_trigger_value}."
      end

      possible_transitions =
        @transition_map[event_type][event_trigger_value]

      return if possible_transitions.empty?
      allowed_transitions = possible_transitions.select(&:allowed?)

      if allowed_transitions.empty?
        @state_machine.log "All transitions are disallowed for "\
          "#{event_type}:#{event_trigger_value}."
      elsif allowed_transitions.count > 1
        list = allowed_transitions.collect do |t|
          "-> #{t.options[:to]}"
        end
        raise RuntimeError,
          "Not sure which transition to trigger "\
          "when #{symbol} while #{self} (allowed: #{list}). "\
          "Please make sure guard conditions exclude each other."
      else
        transition = allowed_transitions.first
        unless transition.nil?
          transition.send :unguarded_execute
        end
      end

    end
def guarded_execute(event_type, event_trigger_value)
      @state_machine.raise_outside_initial_queue

      return if terminating?

      if @transition_map[event_type].nil? ||
         @transition_map[event_type][event_trigger_value].nil?
        raise ArgumentError,
          "No registered transition found "\
          "for event #{event_type}:#{event_trigger_value}."
      end

      possible_transitions =
        @transition_map[event_type][event_trigger_value]

      return if possible_transitions.empty?
      allowed_transitions = possible_transitions.select(&:allowed?)

      if allowed_transitions.empty?
        @state_machine.log "All transitions are disallowed for "\
          "#{event_type}:#{event_trigger_value}."
      elsif allowed_transitions.count > 1
        list = allowed_transitions.collect do |t|
          "-> #{t.options[:to]}"
        end
        raise RuntimeError,
          "Not sure which transition to trigger "\
          "when #{symbol} while #{self} (allowed: #{list}). "\
          "Please make sure guard conditions exclude each other."
      else
        transition = allowed_transitions.first
        unless transition.nil?
          transition.send :unguarded_execute
        end
      end

    end
Executes the registered transition for the given event type and
 event trigger value, if such a transition exists and it is
 allowed.

 @raise [RuntimeError] if multiple transitions would be allowed at
   the same time.