Load the definition of scopes

```json
{
"scope1": [{"methods": "get", path: "/:user/profile"}, "/order"],
"scope2": [{"methods": "post", path: "/:user/profile"}]
}
```
@param {Object} scopes
@returns {Object}
169353
function loadScopes(scopes) {
  var scopeMapping = {};
  if (typeof scopes === 'object') {
    for (var s in scopes) {
      var routes = [];
      var entries = scopes[s];
      debug('Scope: %s routes: %j', s, entries);
      if (Array.isArray(entries)) {
        for (var j = 0, k = entries.length; j < k; j++) {
          var route = entries[j];
          if (typeof route === 'string') {
            routes.push({methods: ['all'], path: route,
              regexp: pathToRegexp(route, [], {end: false})});
          } else {
            var methods = helpers.normalizeList(methods);
            if (methods.length === 0) {
              methods.push('all');
            }
            methods = methods.map(toLowerCase);
            routes.push({methods: methods,
              path: route.path,
              regexp: pathToRegexp(route.path, [], {end: false})});
          }
        }
      } else {
        debug('Routes must be an array: %j', entries);
      }
      scopeMapping[s] = routes;
    }
  } else if (typeof scopes === 'string') {
    scopes = helpers.normalizeList(scopes);
    for (var i = 0, n = scopes.length; i < n; i++) {
      scopeMapping[scopes[i]] = [
        {methods: 'all', path: '/.+', regexp: /\/.+/}
      ];
    }
  }
  return scopeMapping;
}
549838
public function scopes(array $scopes)
    {
        $builder = $this;

        foreach ($scopes as $scope => $parameters) {
            // If the scope key is an integer, then the scope was passed as the value and
            // the parameter list is empty, so we will format the scope name and these
            // parameters here. Then, we'll be ready to call the scope on the model.
            if (is_int($scope)) {
                [$scope, $parameters] = [$parameters, []];
            }

            // Next we'll pass the scope callback to the callScope method which will take
            // care of grouping the "wheres" properly so the logical order doesn't get
            // messed up when adding scopes. Then we'll return back out the builder.
            $builder = $builder->callScope(
                [$this->model, 'scope'.ucfirst($scope)],
                (array) $parameters
            );
        }

        return $builder;
    }
528623
def _parse(cls, scope):
    
    if not scope:
      return ('default',)
    if isinstance(scope, string_types):
      scope = scope.split(' ')
    scope = {str(s).lower() for s in scope if s}
    return scope or ('default',)
405407
def decode_scopes(scopes)
      if scopes.is_a?(Array)
        scopes.map {|s| s.to_s.strip }
      else
        scopes.to_s.split(' ').map {|s| s.strip }
      end
    end
617710
def unpack_scope(cls, scope):
        """"""
        query = {}
        projection = {}
        options = {}

        if isinstance(scope, tuple):
            if len(scope) > 3:
                raise ValueError("Invalid scope")
            if len(scope) >= 1:
                query = scope[0]
            if len(scope) >= 2:
                projection = scope[1]
            if len(scope) == 3:
                options = scope[2]
        elif isinstance(scope, dict):
            query = scope
        else:
            raise ValueError("Invalid scope")

        return query, projection, options
1253939
public function applyScopesToUser($user, array $scopes)
	{
		if (! is_a($user, Model::class)) {
			$this->fail('User is not a model.');
		}

		$scopes = array_map(
			function ($scope) {
				return ['oauth_scope_id' => $scope];
			}, $scopes
		);

		$user->scopes()->attach($scopes);

		return $user->fresh(['scopes']);
	}
559490
def get_scope(self, scope_name):
        """"""
        request_url = self._build_url(['Scope', scope_name])
        return self._do_request('GET', request_url)
973696
function (scope, key) {
                    if (!key) {
                        key = scope;
                        scope = this;
                    }

                    if (!key) {
                        return null;
                    }

                    var path;

                    // if we have a path object
                    if (_.isArray(key)) {
                        path = key;
                        // path element
                    } else if (_.isObject(key)) {
                        path = [key];
                    } else {
                        path = Parser.parse(key, RULE_PATH);
                    }

                    var pathElement, val,
                        parameters, fnc,
                        newParameters;
                    for (var j = 0; j < path.length; j++) {
                        if (scope == null) {
                            return undefined;
                        } else {
                            pathElement = path[j];
                            if (pathElement.type == "fnc") {
                                fnc = scope[pathElement.name];
                                parameters = pathElement.parameter;
                                newParameters = [];
                                for (var i = 0; i < parameters.length; i++) {
                                    var param = parameters[i];

                                    if (_.isArray(param)) {
                                        param = this.get(param);
                                    } else if (_.isObject(param) && param.type && param.path) {
                                        param = this.get(param.path);
                                    }
                                    newParameters.push(param);
                                }
                                scope = fnc.apply(scope, newParameters);
                            } else if (pathElement.type == "var") {
                                if (scope instanceof Bindable) {
                                    if (path.length - 1 === j) {
                                        val = scope.$[pathElement.name];
                                        if (_.isUndefined(val)) {
                                            val = scope[pathElement.name];
                                        }
                                        scope = val;
                                    } else {
                                        scope = scope.get(pathElement.name);
                                    }

                                } else {
                                    scope = scope[pathElement.name];
                                }
                            }

                            if (scope && pathElement.index != null) {
                                // if it's an array
                                if (_.isArray(scope)) {
                                    scope = scope[pathElement.index];
                                    // if it's a list
                                } else if (scope.at) {
                                    scope = scope.at(pathElement.index);
                                }
                            }
                        }
                    }
                    return scope;
                }
511132
private WebSocketScope getScope(WebSocketConnection conn) {
        if (log.isTraceEnabled()) {
            log.trace("Scopes: {}", scopes);
        }
        log.debug("getScope: {}", conn);
        WebSocketScope wsScope;
        String path = conn.getPath();
        if (!scopes.containsKey(path)) {
            // check for default scope
            if (!scopes.containsKey("default")) {
                wsScope = new WebSocketScope();
                wsScope.setPath(path);
                notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
                addWebSocketScope(wsScope);
                //log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
            } else {
                path = "default";
            }
        }
        wsScope = scopes.get(path);
        log.debug("Returning: {}", wsScope);
        return wsScope;
    }
250745
@Beta
  public GoogleCredential createScoped(Collection<String> scopes) {
    if (serviceAccountPrivateKey == null) {
      return this;
    }
    return toBuilder()
        .setServiceAccountScopes(scopes)
        .build();
  }
977420
def _collect_scopes(handlers, scopes, user, client):
    
    results = set()

    data = {'user': user, 'client': client}

    def visitor(scope_name, func):
        claim_names = func(data)
        # If the claim_names is None, it means that the scope is not authorized.
        if claim_names is not None:
            results.add(scope_name)

    _visit_handlers(handlers, visitor, 'scope', scopes)

    return results
270727
def tasks_in_scope(scope)
      prefix = scope.join(":")
      tasks.select { |t|
        /^#{prefix}:/ =~ t.name
      }
    end
1080886
def create_scope(self, info, scope_id):
        
        route_values = {}
        if scope_id is not None:
            route_values['scopeId'] = self._serialize.url('scope_id', scope_id, 'str')
        content = self._serialize.body(info, 'CreateScopeInfo')
        response = self._send(http_method='PUT',
                              location_id='4e11e2bf-1e79-4eb5-8f34-a6337bd0de38',
                              version='5.0-preview.2',
                              route_values=route_values,
                              content=content)
        return self._deserialize('IdentityScope', response)
1274879
def lookup_in_scope(name, scope)
      n = scope.size
      while n >= 0
        tn = (scope[0,n] + [name]).join(':')
        task = @tasks[tn]
        return task if task
        n -= 1
      end
      nil
    end
529178
def scopes(cls):
        
        # Why do we need this? This should either
        # * Be bubbled to the places where it is used (AcidXBlock).
        # * Be automatic. Look for all members of a type.
        return [cls.USAGE, cls.DEFINITION, cls.TYPE, cls.ALL]
1349466
def extract_scopes(self, request):
        
        payload = self.extract_payload(request)
        if not payload:
            return None

        scopes_attribute = self.config.scopes_name()
        return payload.get(scopes_attribute, None)
562489
def _get_scopes(self):
        
        if self._read_only:
            scopes = (READ_ONLY_SCOPE,)
        else:
            scopes = (DATA_SCOPE,)

        if self._admin:
            scopes += (ADMIN_SCOPE,)

        return scopes