addon/state-manager.js
function sendRecursively(event, currentState, isUnhandledPass) {
  var log = this.enableLogging,
      eventName = isUnhandledPass ? 'unhandledEvent' : event,
      action = currentState[eventName],
      contexts, sendRecursiveArguments, actionArguments;

  contexts = [].slice.call(arguments, 3);

  // Test to see if the action is a method that
  // can be invoked. Don't blindly check just for
  // existence, because it is possible the state
  // manager has a child state of the given name,
  // and we should still raise an exception in that
  // case.
  if (typeof action === 'function') {
    if (log) {
      if (isUnhandledPass) {
        Ember.Logger.log(`STATEMANAGER: Unhandled event '${event}' being sent to state ${currentState.get('path')}.`);
      } else {
        Ember.Logger.log(`STATEMANAGER: Sending event '${event}' to state ${currentState.get('path')}.`);
      }
    }

    actionArguments = contexts;
    if (isUnhandledPass) {
      actionArguments.unshift(event);
    }
    actionArguments.unshift(this);

    return action.apply(currentState, actionArguments);
  } else {
    var parentState = get(currentState, 'parentState');
    if (parentState) {

      sendRecursiveArguments = contexts;
      sendRecursiveArguments.unshift(event, parentState, isUnhandledPass);

      return sendRecursively.apply(this, sendRecursiveArguments);
    } else if (!isUnhandledPass) {
      return sendEvent.call(this, event, contexts, true);
    }
  }
}
function sendRecursively(event, currentState, isUnhandledPass) {
  var log = this.enableLogging,
      eventName = isUnhandledPass ? 'unhandledEvent' : event,
      action = currentState[eventName],
      contexts, sendRecursiveArguments, actionArguments;

  contexts = [].slice.call(arguments, 3);

  // Test to see if the action is a method that
  // can be invoked. Don't blindly check just for
  // existence, because it is possible the state
  // manager has a child state of the given name,
  // and we should still raise an exception in that
  // case.
  if (typeof action === 'function') {
    if (log) {
      if (isUnhandledPass) {
        Ember.Logger.log(`STATEMANAGER: Unhandled event '${event}' being sent to state ${currentState.get('path')}.`);
      } else {
        Ember.Logger.log(`STATEMANAGER: Sending event '${event}' to state ${currentState.get('path')}.`);
      }
    }

    actionArguments = contexts;
    if (isUnhandledPass) {
      actionArguments.unshift(event);
    }
    actionArguments.unshift(this);

    return action.apply(currentState, actionArguments);
  } else {
    var parentState = get(currentState, 'parentState');
    if (parentState) {

      sendRecursiveArguments = contexts;
      sendRecursiveArguments.unshift(event, parentState, isUnhandledPass);

      return sendRecursively.apply(this, sendRecursiveArguments);
    } else if (!isUnhandledPass) {
      return sendEvent.call(this, event, contexts, true);
    }
  }
}
function sendRecursively ( event , currentState , isUnhandledPass ) { var log = this . enableLogging , eventName = isUnhandledPass ? 'unhandledEvent' : event , action = currentState [ eventName ] , contexts , sendRecursiveArguments , actionArguments ; contexts = [ ] . slice . call ( arguments , 3 ) ; // Test to see if the action is a method that // can be invoked. Don't blindly check just for // existence, because it is possible the state // manager has a child state of the given name, // and we should still raise an exception in that // case. if ( typeof action === 'function' ) { if ( log ) { if ( isUnhandledPass ) { Ember . Logger . log ( ` ${ event } ${ currentState . get ( 'path' ) } ` ) ; } else { Ember . Logger . log ( ` ${ event } ${ currentState . get ( 'path' ) } ` ) ; } } actionArguments = contexts ; if ( isUnhandledPass ) { actionArguments . unshift ( event ) ; } actionArguments . unshift ( this ) ; return action . apply ( currentState , actionArguments ) ; } else { var parentState = get ( currentState , 'parentState' ) ; if ( parentState ) { sendRecursiveArguments = contexts ; sendRecursiveArguments . unshift ( event , parentState , isUnhandledPass ) ; return sendRecursively . apply ( this , sendRecursiveArguments ) ; } else if ( ! isUnhandledPass ) { return sendEvent . call ( this , event , contexts , true ) ; } } }
Sends the event to the currentState, if the event is not handled this method
will proceed to call the parentState recursively until it encounters an
event handler or reaches the top or root of the state path hierarchy.

@method sendRecursively
@param event
@param currentState
@param isUnhandledPass
Sends the event to the currentState if the event is not handled this method will proceed to call the parentState recursively until it encounters an event handler or reaches the top or root of the state path hierarchy .