def _save_rest_method(self, method_name, api_name, version, method):
path_pattern = '<STR_LIT:/>'.join((api_name, version, method.get('<STR_LIT:path>', '<STR_LIT>')))<EOL>http_method = method.get('<STR_LIT>', '<STR_LIT>').lower()<EOL>for _, path, methods in self._rest_methods:<EOL><INDENT>if path == path_pattern:<EOL><INDENT>methods[http_method] = method_name, method<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._rest_methods.append(<EOL>(self._compile_path_pattern(path_pattern),<EOL>path_pattern,<EOL>{http_method: (method_name, method)}))<EOL><DEDENT>
Store Rest api methods in a list for lookup at call time.

        The list is self._rest_methods, a list of tuples:
          [(<compiled_path>, <path_pattern>, <method_dict>), ...]
        where:
          <compiled_path> is a compiled regex to match against the incoming URL
          <path_pattern> is a string representing the original path pattern,
            checked on insertion to prevent duplicates.     -and-
          <method_dict> is a dict of httpMethod => (method_name, method)

        This structure is a bit complex, it supports use in two contexts:
          Creation time:
            - SaveRestMethod is called repeatedly, each method will have a path,
              which we want to be compiled for fast lookup at call time
            - We want to prevent duplicate incoming path patterns, so store the
              un-compiled path, not counting on a compiled regex being a stable
              comparison as it is not documented as being stable for this use.
            - Need to store the method that will be mapped at calltime.
            - Different methods may have the same path but different http method.
          Call time:
            - Quickly scan through the list attempting .match(path) on each
              compiled regex to find the path that matches.
            - When a path is matched, look up the API method from the request
              and get the method name and method config for the matching
              API method and method name.

        Args:
          method_name: A string containing the name of the API method.
          api_name: A string containing the name of the API.
          version: A string containing the version of the API.
          method: A dict containing the method descriptor (as in the api config
            file).