Runs the machine's +before+ callbacks for this transition.  Only
 callbacks that are configured to match the event, from state, and to
 state will be invoked.

 Once the callbacks are run, they cannot be run again until this transition
 is reset.
3232
def before(complete = true, index = 0, &block)
        unless @before_run
          while callback = machine.callbacks[:before][index]
            index += 1
            
            if callback.type == :around
              # Around callback: need to handle recursively.  Execution only gets
              # paused if:
              # * The block fails and the callback doesn't run on failures OR
              # * The block succeeds, but after callbacks are disabled (in which
              #   case a continuation is stored for later execution)
              return if catch(:cancel) do
                callback.call(object, context, self) do
                  before(complete, index, &block)
                  
                  pause if @success && !complete
                  throw :cancel, true unless @success
                end
              end
            else
              # Normal before callback
              callback.call(object, context, self)
            end
          end
          
          @before_run = true
        end
        
        action = {:success => true}.merge(block_given? ? yield : {})
        @result, @success = action[:result], action[:success]
      end
374798
function(event) {
            var state = self.state();

            for ( var i in self._callbacks ) {
                self._callbacks[i].call(self._doc, event, state);
            }
        }
395737
def run_callbacks_for(name, args, reverse)
      callbacks_for(name, reverse).map do |block|
        run_callback(block, args)
      end
    end
1316386
function(state, transitionContext)
  {
    // this check is necessary to make sure we don't re-enter a transient state
    // like Renewing when we're already in it
    if (currentState !== state)
    {
      // if we have a current state, exit it; the null check is necessary
      // because the currentState is undefined at bootstrap time when we
      // transition to the first state
      if (currentState)
      {
        currentState.exit();
      }

      // update the current state
      currentState = state;

      // enter the new state
      currentState.enter(transitionContext);
    }
  }
553668
def _pre_transition_checks(self):
        """"""
        current_state = getattr(self.instance, self.field_name)
        if current_state not in self.transition.source:
            raise InvalidTransitionError(
                "Transition '%s' isn't available from state '%s'." %
                (self.transition.name, current_state.name))

        for check in self._filter_hooks(HOOK_CHECK):
            if not check(self.instance):
                raise ForbiddenTransition(
                    "Transition '%s' was forbidden by "
                    "custom pre-transition check." % self.transition.name)
450327
public function runBefore() {
        if($this->_beforeController !== null) {
            foreach($this->_beforeController as $hookProvider) {
                $hookProvider->doBefore();
            }
        }
    }
481920
def _run_callbacks(kind, *args) #:nodoc:
      options = args.last # Last callback arg MUST be a Hash

      send("_#{kind}").each do |callback, conditions|
        invalid = conditions.find do |key, value|
          value.is_a?(Array) ? !value.include?(options[key]) : (value != options[key])
        end

        callback.call(*args) unless invalid
      end
    end
1264140
public function runBeforeSystem() {
        if($this->_beforeSystem !== null) {
            foreach($this->_beforeSystem as $hookProvider) {
                $hookProvider->doBeforeSystem();
            }
        }
    }
914891
def after_check
      @checkers.each do |checker|
        after_check_callbacks = checker.class.get_callbacks(:after_check)
        after_check_callbacks.each do |block|
          checker.instance_exec &block
        end
      end
    end
498964
def run(self):
        ''''''
        while not self.wait(self.delay()):
            try:
                logger.info('Invoking callback %s', self.callback)
                self.callback()
            except StandardError:
                logger.exception('Callback failed')
242774
function runBeforeDetach (args, methodMeta) {
    // skip if no beforeDetach methods
    if (!defined(methodMeta.beforeDetach)) {
        return
    }
    // run all functions
    _.each(methodMeta.beforeDetach, method => {
        // call method
        (method)(args, methodMeta.signature, 'beforeDetach')
        // log errors
        .catch(err => {
            // require log client
            if (!defined(methodMeta.logClient)) {
                return
            }
            // log error
            methodMeta.logClient.error(err, args.session)
        })
    })
}
443666
function resetSuite() {
    var event,
        me = this,
        aborting = calledBy.abortSuite;

    if (me.running && !aborting) {
      // no worries, `resetSuite()` is called within `abortSuite()`
      calledBy.resetSuite = true;
      me.abort();
      delete calledBy.resetSuite;
    }
    // reset if the state has changed
    else if ((me.aborted || me.running) &&
        (me.emit(event = Event('reset')), !event.cancelled)) {
      me.running = false;
      if (!aborting) {
        invoke(me, 'reset');
      }
    }
    return me;
  }
1282504
def fire_events(object, *events)
      run_action = [true, false].include?(events.last) ? events.pop : true
      
      # Generate the transitions to run for each event
      transitions = events.collect do |event_name|
        # Find the actual event being run
        event = nil
        detect {|name, machine| event = machine.events[event_name, :qualified_name]}
        
        raise(InvalidEvent.new(object, event_name)) unless event
        
        # Get the transition that will be performed for the event
        unless transition = event.transition_for(object)
          event.on_failure(object)
        end
        
        transition
      end.compact
      
      # Run the events in parallel only if valid transitions were found for
      # all of them
      if events.length == transitions.length
        TransitionCollection.new(transitions, :actions => run_action).perform
      else
        false
      end
    end
1278256
def defer(callable, trans_event, *data)
      async_call = AsyncCall.new(machine, callable, trans_event, *data)
      callback_queue.start unless callback_queue.running?
      callback_queue << async_call
    end
52018
def cancel(self):
        
        with self._condition:
            if self._state in [RUNNING, FINISHED]:
                return False

            if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                return True

            self._state = CANCELLED
            self._condition.notify_all()

        self._invoke_callbacks()
        return True
337647
def state_callback(before_or_after = :before)
      method_name = :"#{before_or_after}_#{@order.state}"
      send(method_name) if respond_to?(method_name, true)
    end
585991
protected function runApplicationWithEvents()
    {
        $this->prepareEnvironment();

        if (static::$before) {
            $this->runBeforeCallbacks();
        }
        // read configs/general.php for register aliases
        $this->readGeneralConfigs();
        // register all aliases
        $this->registerAliases();
        // register helpers;
        $this->resolveHelpers();

        //execute the service providers
        $this->prepareServiceProviders();

        if (static::$after) {
            $this->runAfterCallbacks();
        }
    }