#check(action)

 @param action [Pause::Action]
 @return [nil]  everything is fine
 @return [false]  this action is already blocked
 @return [Pause::RateLimitedEvent]  the action was blocked as a result of this check
183689
def check(action, recalculate: false)
      return false if adapter.rate_limited?(action.scope, action.identifier) && !recalculate
      timestamp = period_marker(Pause.config.resolution, Time.now.to_i)
      set       = adapter.key_history(action.scope, action.identifier)
      action.checks.each do |period_check|
        start_time = timestamp - period_check.period_seconds
        set.reverse.inject(0) do |sum, element|
          break if element.ts < start_time
          sum += element.count
          if sum >= period_check.max_allowed
            adapter.rate_limit!(action.scope, action.identifier, period_check.block_ttl)
            # Note that Time.now is different from period_marker(resolution, Time.now), which
            # rounds down to the nearest (resolution) seconds
            return Pause::RateLimitedEvent.new(action, period_check, sum, Time.now.to_i)
          end
          sum
        end
      end
      nil
    end
862059
private boolean checkActionMethod(AppController controller, String actionMethod) {
        HttpMethod method = HttpMethod.getMethod(RequestContext.getHttpRequest());
        if (!controller.actionSupportsHttpMethod(actionMethod, method)) {
            DirectResponse res = new DirectResponse("");
            //see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
            res.setStatus(405);
            LOGGER.warn("Requested action does not support HTTP method: " + method.name() + ", returning status code 405.");
            RequestContext.setControllerResponse(res);

            //TODO: candidate for caching below, list of allowed HTTP methods
            //see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
            RequestContext.getHttpResponse().setHeader("Allow", join(controller.allowedActions(actionMethod), ", "));
            return false;
        }
        return true;
    }
885566
private <R> R doWithReadLock(Action<K, V, R> action) {
        readLock.lock();
        try {
            return action.doWith(commonCache);
        } finally {
            readLock.unlock();
        }
    }
100164
def respond_to_action(action)
      type = action[:type].to_sym
      state = action[:state].to_sym
      actions = []
      if type == :grid
        actions += responses[:"grid#{action[:x]}#{action[:y]}"][state]
        actions += responses[:"grid#{action[:x]}-"][state]
        actions += responses[:"grid-#{action[:y]}"][state]
      end
      actions += responses[type][state]
      actions += responses[:all][state]
      actions.compact.each {|block| block.call(self, action)}
      nil
    rescue Exception => e
      logger.error "error when responding to action #{action.inspect}: #{e.inspect}"
      raise e
    end
1261159
private <R> R doWithReadLock(Action<K, V, R> action) {
        long stamp = sl.tryOptimisticRead();
        R result = action.doWith(commonCache);

        if (!sl.validate(stamp)) {
            stamp = sl.readLock();
            try {
                result = action.doWith(commonCache);
            } finally {
                sl.unlockRead(stamp);
            }
        }

        return result;
    }
146117
@Check(CheckType.FAST)
	public void checkActionFires(SarlAction action) {
		for (final JvmTypeReference event : action.getFiredEvents()) {
			final LightweightTypeReference ref = toLightweightTypeReference(event);
			if (ref != null && !this.inheritanceHelper.isSarlEvent(ref)) {
				error(MessageFormat.format(
						Messages.SARLValidator_57,
						event.getQualifiedName(),
						Messages.SARLValidator_62,
						this.grammarAccess.getFiresKeyword()),
						event,
						null,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						INVALID_FIRING_EVENT_TYPE,
						event.getSimpleName());
			}
		}
	}
1063706
public boolean checkResource(String resource, Action action, OrientPermission[] permissions)
	{
		String actionName = action.getName();
		int actionIndx = resource.indexOf(':');
		if(actionIndx>0) {
			if(!(resource.endsWith(actionName) && resource.length()>actionName.length() 
					&& resource.charAt(resource.length()-actionName.length()-1) == ':')) return true;
			else resource = resource.substring(0, actionIndx);//Should cut off action
		} else if(!Component.RENDER.equals(action)) return true; //Default suffix is for render: so other should be skipped
		
		OSecurityUser user = OrientDbWebSession.get().getUser();
		if(user==null) return false;
		ORule.ResourceGeneric generic = OSecurityHelper.getResourceGeneric(resource);
		String specific = OSecurityHelper.getResourceSpecific(resource);
		
		return user!=null
				?user.checkIfAllowed(generic, specific, OrientPermission.combinedPermission(permissions))!=null
				:false;
	}
1332390
public ElementActionBuilder checkInput(boolean checked) {
		CheckInputAction action = new CheckInputAction();
		action.setChecked(checked);
        action(action);
        return new ElementActionBuilder(action);
    }
1061761
def remove(action)
      raise ArgumentError.new('Expecting an action') unless action.is_a?(Action)
      @actions.delete(action)
      wakeup if running?
    end
1082921
public function checkAccessAction($action) {
    $method = $this->request->httpMethod();
    $apiActions = Config::inst()->get(get_class($this), 'api_allowed_actions');
    $isAllowed = false;
    if ($apiActions === null) {
      // all actions + methods are allowed, use default check
      return parent::checkAccessAction($action);
    } else if ($apiActions === true) {
      return true;
    }
    if (is_array($apiActions)) {
      foreach($apiActions as $apiAction => $permission) {
        preg_match("/^(.+?):(.+)$/", $apiAction, $matches);
        if ((!isset($matches[1]))||(!isset($matches[2]))) {
          return user_error("Ensure that `api_allowed_actions` fulfills the following pattern: `\$method:\$action` => `\$permission`");
        }
        $allowedMethod = strtoupper($matches[1]);
        $allowedAction = $matches[2];
        if ((($allowedMethod === $method)||($allowedMethod === "*")) && ($allowedAction === $action)) {
          if ($permission === true) {
            // wildcard
            $isAllowed = true;
          } else if ($permission === '->') {
            $isAllowed = true;
          } else if (substr($permission,0,2) === '->') {
            // use method
            $permissionMethod = substr($permission,2);
            if (!$this->hasMethod($permissionMethod)) {
              return user_error("Permission method `$permissionMethod` doesn't exists on `$this->class`");
            } else {
              $isAllowed = $this->{$permissionMethod}();
            }
          } else {
            $isAllowed = Permission::check($permission);
          }
        }
      }
    }
    return $isAllowed;
  }
735722
private <R> R doWithWriteLock(Action<K, V, R> action) {
        writeLock.lock();
        try {
            return action.doWith(commonCache);
        } finally {
            writeLock.unlock();
        }
    }
1147188
private void checkAndCancelExpiredAction(final Action action) {
        if (action != null && action.hasMaintenanceSchedule() && action.isMaintenanceScheduleLapsed()) {
            try {
                controllerManagement.cancelAction(action.getId());
            } catch (final CancelActionNotAllowedException e) {
                LOG.info("Cancel action not allowed exception :{}", e);
            }
        }
    }
796440
def validate_host_port(action)
      raise JSS::UnsupportedError, "Cannot #{action} without first setting a host_name and port" if host_name.to_s.empty? || port.to_s.empty?
    end
1319595
public boolean check() {
        if (!method.getReturnType().equals(Void.TYPE)) {
            WebSocketRouter.getLogger().error("The method {} annotated with a web socket callback is not well-formed. " +
                            "These methods receive only parameter annotated with @Parameter and do not return anything",
                    method.getName()
            );
            return false;
        }

        List<ActionParameter> localArguments = buildArguments(method);
        if (localArguments == null) {
            return false;
        } else {
            this.arguments = localArguments;
            return true;
        }
    }
249723
function shouldBeChecked(actionType: string): bool {
  if(actionType === LIST_ITEM_CHECK)    return true;
  if(actionType === LIST_ITEM_UNCHECK)  return false;

  throw new Error(`Invalid action type ${actionType}`);
}
677409
def check goal=nil, &block
      goal ||= block
      result = nil
      begin 
        result = goal.true?
      rescue
        check_raised_exception goal, $!
      else
        if result
          check_passed goal, &block
        else
          check_failed goal, &block
        end
      end
      result
    end
853442
def lookup_action #:nodoc:
      @lookup_action ||= begin
        action = template.controller && template.controller.action_name
        return unless action
        action = action.to_s
        ACTIONS[action] || action
      end
    end