generates the allowed methods
344804
function allowedMethods(methods) {
  // default values
  var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false  };
  // check and override if one of the default methods
  for (var key in methods) {
    var newKey = key.toUpperCase();
    if ( methodsAllowed[newKey]!=undefined) {
      methodsAllowed[newKey] = Boolean(methods[key]);
    }
  }
  return methodsAllowed;
}
726122
public Collection<String> getAllowedMethods(String requestMethod) {

		Constraint.ensureNotEmpty(requestMethod, String.format("Invalid method '%s'", requestMethod));
		Set<String> rtAllowedMethods = new HashSet<String>(allowedMethods);
		rtAllowedMethods.add(requestMethod.toUpperCase());

		return rtAllowedMethods;
	}
543916
function addDecoratorMethods() {
        $methods = $this->decoratorReflection->getMethods();

        foreach ($methods as $method) {
            $name = $method->getName();

            if ($name === '__construct' || $name === '__prototype' || $name == '__extend') {
                continue;
            }

            $methodGenerator = MethodGenerator::fromReflection($method);
            $this->generator->addMethodFromGenerator($methodGenerator);
        }
    }
22074
def _guess_available_methods(self):
        
        available_methods = []
        for m in ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]:
            self_method = getattr(type(self), "API_{}".format(m))
            super_method = getattr(APIPage, "API_{}".format(m))
            if self_method != super_method:
                available_methods.append(m)
        return available_methods
1326003
function customizeMethods(custom) {
  _.each(custom, function(classMethods, className) {
    _.extend(xml2js.CLASSES[className].methods, _.pick(classMethods, function(methodSpec, methodName) {
      return isValidMethodSpec(methodSpec, className + '.' + methodName);
    }));
  });
}
733998
function createMethod() {
    if( !isset( $this->method ))
      return;
    switch( $this->format ) {
      case 'xcal':
        return ' method="'.$this->method.'"'.$this->nl;
        break;
      default:
        return 'METHOD:'.$this->method.$this->nl;
        break;
    }
  }
332743
protected MethodSpec.Builder generateMethodBuilder(SQLiteModelMethod method) {
		MethodSpec.Builder methodBuilder;
		if (method.hasLiveData()) {
			methodBuilder = MethodSpec.methodBuilder(method.getName() + LIVE_DATA_PREFIX).addModifiers(Modifier.PROTECTED);
		} else {
			methodBuilder = MethodSpec.methodBuilder(method.getName()).addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);
		}

		return methodBuilder;
	}
47615
def check_method_allowed(cls, request):
        
        if not request.method in cls._meta.allowed_methods:
            raise HttpError(
                'Method \'%s\' not allowed on this resource.' % request.method,
                status=status.HTTP_405_METHOD_NOT_ALLOWED)
155618
def generate_method_definition(func):
    
    indent = 4

    # initial definition
    method_definition = (" " * indent) + "def " + func["name"]

    # Here we just create a queue and put all the parameters
    # into the queue in the order that they were given,
    params_required = [
        param for param in func["arguments"] if param["is_required"]
    ]
    params_optional = [
        param for param in func["arguments"]
        if not param["is_required"]
    ]

    # Open the parameter definitions
    method_definition += "(self, "

    for param in params_required:
        # Put the parameter into the queue

        method_definition += param["name"]
        method_definition += ", "

    for param in params_optional:
        method_definition += param["name"]

        # Default methods not required
        method_definition += "=None, "

    # Peel off the final ", " and close off the parameter definition
    method_definition = method_definition.rstrip(", ") + "):\n"

    indent += 4

    # re-indent
    method_definition += " " * indent

    # Begin with description.

    method_definition += '"""' + func["description"]

    # re-indent
    method_definition += "\n\n" + " " * indent

    # Go through each parameter and insert description & type hint
    for param in params_required + params_optional:
        # Add the type
        method_definition += ":param " + DTYPE_MAPPING[param["type"].lower()]

        # Add the name
        method_definition += " " + param["name"] + ": "

        # Add the description
        method_definition += param["description"]

        # Add optionality & reindent
        method_definition += "\n" if param[
            "is_required"] else " (Optional)\n"

        method_definition += " " * indent

    open_index = func["returns"].find('(')
    close_index = func["returns"].find(
        ')', (open_index if open_index > -1 else 0))

    func["returns"] = func["returns"].replace("\t", " " * 4)
    return_string = func["returns"].replace("\n", "")

    if open_index < close_index and func["returns"][
                                    open_index + 1:close_index] in DTYPE_MAPPING:
        method_definition += ":rtype: " + DTYPE_MAPPING[
            func["returns"][open_index + 1:close_index]]

        func["returns"] = func["returns"].replace(
            func["returns"][open_index:close_index + 1], "")

        method_definition += "\n" + " " * indent

    method_definition += ":return: " + return_string

    for i in range(0, len(return_string) + 1, 80 - (indent + 2)):
        method_definition += return_string[i:i + (
                80 - (indent + 2))] + "\n" + " " * indent

    # Close it off & reindent
    method_definition += '"""' + "\n" + " " * indent

    # Create the params map
    params_map = "__params_map = {"

    # Save the indent
    params_indent, num_params = len(
        params_map), len(params_required) + len(params_optional)

    # Append the map to the method_definition
    method_definition += params_map

    # Go through the required parameters first
    for i, param in enumerate(params_required + params_optional):

        # append the methods to the map
        method_definition += "'" + param["name"] + "': " + param["name"]

        if not param["is_required"]:
            method_definition + " if " + param[
                "name"] + "is not None else None"

        # add commas or ending bracket if needed & reindent correctly
        method_definition += ",\n" + " " * indent + ' ' * params_indent if i + 1 < num_params else ""

    method_definition += '}\n\n' + ' ' * indent

    method_definition += "return self.make_request(SERVER_ADDRESS, '" + func["name"] + "', " \
                         + params_map.rstrip(" = {") + ", timeout=self.timeout)\n\n"

    return method_definition
1182840
function validateMethods() {
  xml2js.METHODS = _.pick(xml2js.METHODS, function(methodSpec, methodName) {
    return hasValidTypes(methodSpec, methodName);
  });
  _.each(xml2js.CLASSES, function(classSpec, className) {
    var valid = _.pick(classSpec.methods, function(methodSpec, methodName) {
      return hasValidTypes(methodSpec, className + '.' + methodName, className);
    });
    if (xml2js.opts.strict) {
      xml2js.CLASSES[className].methods = valid;
    }
  });
}
1357956
private static String[] getAllowedMethods(String[] existingMethods) {
        int listCapacity = existingMethods.length + 1;

        List<String> allowedMethods = new ArrayList<>(listCapacity);

        allowedMethods.addAll(Arrays.asList(existingMethods));
        allowedMethods.add(METHOD_PATCH);

        return allowedMethods.toArray(new String[0]);
    }
1341429
protected function buildMethods()
    {
        $refl = new \ReflectionClass($this);
        $enterMethods = [];
        $leaveMethods = [];

        foreach ($refl->getMethods() as $method) {
            $name = $method->getName();
            if (preg_match('/^(enter|leave).+/', $name) && !preg_match('/^(enter|leave)Node$/', $name)) {
                $params = $method->getParameters();
                if ($params && $params[0]->getClass()) {
                    $nodeType = $params[0]->getClass()->getName();
                    if (Text::startsWith($name, 'enter')) {
                        $enterMethods[$nodeType][] = $name;
                    } else {
                        $leaveMethods[$nodeType][] = $name;
                    }
                }
            }
        }
        self::$enterMethods[get_class($this)] = $enterMethods;
        self::$leaveMethods[get_class($this)] = $leaveMethods;
    }
110761
public function generate() {

		$methods   = array(); // Actual validation methods
		$rules     = array(); // Individual field rules
		$messages  = array(); // Field error messages
		$php_rules = $this->validator->get_rules();


		foreach($php_rules as $field_name => $field_rules) {

			$rules[$field_name] = array();

			foreach($field_rules as $rule) {

				if( ! ($rule instanceof jQueryValidationRule) ) continue;
				$rule_name = $rule->jquery__get_rule_name();


				if(!isset($methods[$rule_name])) {
					$method = method_exists($rule, 'jquery__get_method_definition') ? $rule->jquery__get_method_definition() : null;
					if($method) $methods[$rule_name] = $method;
				}


				$js_rule = $rule->jquery__get_rule_definition();

				if(is_array($js_rule)) {
					$rules[$field_name] = array_merge($rules[$field_name], $js_rule);
				} else {
					$rules[$field_name][$js_rule] = true;
				}


				$messages[$field_name][$rule_name] = $rule->get_error_message($field_name, null, $this->validator);

			}

			if(empty($rules[$field_name])) unset($rules[$field_name]);
			if(empty($messages[$field_name])) unset($messages[$field_name]);

		}


		return array(
			'rules'    => $rules,
			'messages' => $messages,
			'methods'  => $methods,
		);

	}
1040253
function generate(allows) {
  return function (req, res, next) {
    req.route.allows = allows;
    next();
  };
}
1076838
public static function generateDoxygenDocumentation()
	{
		foreach (static::$methods as $methodName => $m) {
			@ list($realMethod, $buffer, $label) = $m;
			echo "/**\n";
			echo "@memberof ", get_called_class(), "\n";
			if ($realMethod == 'setFlag') {
				echo "@fn $methodName()\n";
			} else {
				echo "@fn $methodName(\$sql_statement, ...)\n";
				echo "@param \$sql_statement SQL statement (a fragment of SQL query) with placeholders.\n";
				echo "@param ... Values of placeholders (when positional placeholders are used).\n";
			}
			echo "@public\n";
			if ($realMethod == 'setFlag') {
				echo "@brief Sets content of buffer `$buffer` to `$label`.\n";
			} else if (substr($realMethod, 0, 3) == 'add') {
				if ($label) {
					echo "@brief Appends `\$sql_statement` prefixed with `$label` to buffer `$buffer`.\n";
				} else {
					echo "@brief Appends `\$sql_statement` to buffer `$buffer`.\n";
				}
			} else {
				if ($label) {
					echo "@brief Replaces content of buffer `$buffer` with `\$sql_statement` prefixed with `$label`.\n";
				} else {
					echo "@brief Replaces content of buffer `$buffer` with `\$sql_statement`.\n";
				}
			}
			echo "\n";
			echo "@note This method is generated from FlupdoBuilder::\$methods array. See compileQuery() method for buffer usage.\n";
			echo "*/\n";
			echo "\n";
		}
	}
179571
private function generateMethods(): EntityGenerator
    {
        $this->entityClass
            ->addMethod('getId')
            ->setVisibility('public')
            ->addComment('Returns ' . strtolower($this->entityData['class']) . ' ID' . PHP_EOL)
            ->addComment('@return int')
            ->addBody('return $this->id;')
            ->setReturnType('int');

        foreach ($this->entityData['properties'] as $name => $type) {
            $this
                ->generateGetter($name, $type)
                ->generateSetter($name, $type);
        }

        return $this;
    }
1097648
private void genGetAllMethod(SourceWriter sw, JMethod[] methods,
      TreeLogger treeLogger) {
    sw.println("public DeferredSelector[] getAllSelectors() {return ds;}");
    sw.println("private final DeferredSelector[] ds = new DeferredSelector[] {");
    sw.indent();
    for (JMethod m : methods) {
      Selector selectorAnnotation = m.getAnnotation(Selector.class);
      if (selectorAnnotation == null) {
        continue;
      }
      String selector = selectorAnnotation.value();

      sw.println("new DeferredSelector() {");
      sw.indent();
      sw
          .println("public String getSelector() { return \"" + selector
              + "\"; }");
      sw
          .println("public NodeList<Element> runSelector(Node ctx) { return " +
              (m.getName() + (m.getParameters().length == 0 ? "()" : "(ctx)")) +
              ("NodeList".equals(m.getReturnType().getSimpleSourceName()) ? "" : ".get()") + ";}"
          );
      sw.outdent();
      sw.println("},");
    }
    sw.outdent();
    sw.println("};");
  }