Do we need a static_roles! method? I think so!
543025
def static_role! role_name
      raise ArgumentError, "Take a single role name, was: #{role_name}" if !role_name || !role_name.kind_of_label?
      troles_config.add_valid_roles role_name
      if set_roles role_name      
        define_method :static_roles? do
          true
        end
      end
    end
764884
def check_role(*roles, **args_map):
    
    def f1(func, roles=roles):
        @wraps(func)
        def f2(*args, **kwargs):
            from uliweb import request, error
            
            arguments = {}
            for k, v in args_map.items():
                if v in kwargs:
                    arguments[k] = kwargs[v]
            if not has_role(request.user, *roles, **arguments):
                error(_("You have no roles to visit this page."))
            return func(*args, **kwargs)
        return f2
    return f1
130208
def verify_role!(node, role)
      current_role = node.info['role']
      if current_role.to_sym != role
        raise InvalidNodeRoleError.new(address_for(node), role, current_role)
      end
      role
    end
602312
@CommandArgument
  public void addroles(
      @OptionArgument("username") String username,
      @OptionArgument("roles") String roles) {

    User user = users.get(username);

    if (user != null) {
      user.roles.addAll(Arrays.asList(roles.split(",")));
    } else {
      System.err.println(String.format("User '%s' does not exist", username));
    }

  }
1294373
def role_data_from_results(res, rolename)
      roles = res['roles']
      roles.each do |role|
        return role[0].to_i if role[1] == rolename
      end
      nil
    end
515552
@Override
    public void addRoles(final Collection<String> roles) {
        CommonHelper.assertNotNull("roles", roles);
        this.roles.addAll(roles);
    }
1330016
def has_roles_mask_accessors?
      instance_method_names = instance_methods.map { |method_name| method_name.to_s }
      [roles_attribute_name.to_s, "#{roles_attribute_name}="].all? do |accessor| 
        instance_method_names.include?(accessor)
      end
    end
1007994
def load_role_profile_commands
      if Bebox::Node.count_all_nodes_by_type(project_root, 'nodes') > 0
        self.extend Bebox::RoleCommands
        self.extend Bebox::ProfileCommands
      end
    end
750095
def has_role(self, role):
        
        if isinstance(role, str):
            return role in (role.name for role in self.roles)
        else:
            return role in self.roles
186473
def persist_registered_roles!
      @roles.each do |name, description|
        Sipity::Role.find_or_create_by!(name: name).tap do |role|
          role.description = description
          role.save!
        end
      end
    end
1018702
def require_user_roles(*roles):
    
    def wrapper(f):
        @functools.wraps(f)
        def wrapped(*args, **kwargs):
            if ext.user_authenticated():
                if not ext.flask_login.current_user.has_any_roles(*roles):
                    return abort(403)
            else:
                return abort(401)
            return f(*args, **kwargs)
        return wrapped
    return wrapper
994539
def has_any_roles(self, *roles):
        
        roles = map(utils.slugify, list(roles))

        return True \
            if AuthUserRole.query() \
            .join(AuthUser) \
            .filter(AuthUserRole.name.in_(roles)) \
            .filter(AuthUser.id == self.id) \
            .count() \
            else False
213416
function role_permissions(roles, callback) {
  var permissions = [],
      fetch = [];

  if (roles) {
    // TODO: Here we could do with some caching like Drupal does.
    roles.forEach(function (name, rid) {
      fetch.push(rid);
    });

    // Get permissions for the rids.
    if (fetch) {
      db.query("SELECT rid, permission FROM role_permission WHERE rid IN ($1);", [fetch], function (err, rows) {
        if (err) {
          callback(err, null);
        }

        if (rows.length > 0) {
          rows.forEach(function (row) {
            permissions.push(row.permission);
          });
        }

        callback(null, permissions);
      });
    }
  }
}
472777
def roles=(*role_names)
      role_names = role_names.flat_uniq
      role_names = extract_roles(role_names)
      return nil if role_names.empty?
      set_roles(select_valid_roles role_names)
    end
297887
def role= role
      raise ArgumentError, '#add_role takes a single role String or Symbol as the argument' if !role || role.kind_of?(Array)
      self.roles = role
    end
879077
function sync_roles($user) {
        global $DB;

        $roles = get_ldap_assignable_role_names(2); // Admin user.

        foreach ($roles as $role) {
            $isrole = $this->is_role($user->username, $role);
            if ($isrole === null) {
                continue; // Nothing to sync - role/LDAP contexts not configured.
            }

            // Sync user.
            $systemcontext = context_system::instance();
            if ($isrole) {
                // Following calls will not create duplicates.
                role_assign($role['id'], $user->id, $systemcontext->id, $this->roleauth);
            } else {
                // Unassign only if previously assigned by this plugin.
                role_unassign($role['id'], $user->id, $systemcontext->id, $this->roleauth);
            }
        }
    }
279642
public void setAuthorizingRoles(String roles) {
        // The ConfigAttributeEditor is named incorrectly, so you can't use it
        // to automatically convert the string to a ConfigAttributeDefinition.
        // So, we do it manually :-(

        ConfigAttributeEditor editor = new ConfigAttributeEditor();
        editor.setAsText( roles );
        this.roles = (List<ConfigAttribute>) editor.getValue();
        rolesString = roles;
    }