<commit_before>h2. RoleSystem

The RoleSystem grants or denies access to controllers methods based on membership to role
groups. The group model has a context attribute, which when set to 'role'
will appear in the member's list or roles

This implementation derives some inspiration from <NAME>'s Role Requirement System

Include this in your ApplicationController to make the RoleSystem available for all controllers.

h2. Example

Here is a hypothetical example of how a model can be created to have roles.

<pre>
  <code>
    @group = Group.create_with(:name => 'admin', :description => 'admin role', :context => 'role')
    @member.groups << @group
    @member.roles => [:admin]
  </code>
</pre>

   Used to find the current user (if any)
   This before filter needs to be called BEFORE any role checking.
   A good place for this would be the application.rb file.

<pre>
  <code>
  before_filter { |controller| controller.role_player = :current_user }

  grant_access_to "editor" # editors are allowed 
  grant_access_to "admin", :only => :destroy # Editors can create but not destroy 
  </code>
</pre>

  You can also route around roles for entire controllers like this:
<pre>
  <code>
    class PublicController < AdminOnlyController
      skip_role_system
    end
  </code>
</pre>

  Or you can designate certain actions public and certain actions role-required
  <pre>
    <code>
      class MixedRoleAccessController < ApplicationController

        # Content Editor can only access the "new" action
        grant_access_to :content_editor, :only => [:new, :create]

        # Admin has access to only "destroy" but not "new", "publish" or "create"
        grant_access_to :admin,   :only => [:destroy]

        # Editor has access to "new", "publish" and "create" but not "destroy"
        grant_access_to :editor,  :except => :destroy

        def new;end
        def create;end
        def publish;end
        def destroy;end
      end
    </code>
  </pre>

h2. Valid Options

* :only - Only require the role for a specific actions
* :except - The role is required for all but the specificed action(s)
* :if - A Proc or string to evaluate; a result of true means the role is required.
* :unless - The opposite of if
<commit_msg>Documentation was wrong.<commit_after>h2. RoleSystem

The RoleSystem grants or denies access to controllers methods based on membership to role
groups. The group model has a context attribute, which when set to 'role'
will appear in the member's list or roles

This implementation derives some inspiration from <NAME>'s Role Requirement System

Include this in your ApplicationController to make the RoleSystem available for all controllers.

h2. Example

Here is a hypothetical example of how a model can be created to have roles.

<pre>
  <code>
    @group = Group.create_with(:name => 'admin', :description => 'admin role', :context => 'role')
    @member.groups << @group
    @member.roles => [:admin]
  </code>
</pre>

   Used to find the current user (if any)
   This before filter needs to be called BEFORE any role checking.
   A good place for this would be the application.rb file.

<pre>
  <code>
  before_filter { |controller| controller.role_player = :current_user }

  grant_access_to "editor" # editors are allowed 
  grant_access_to "admin", :only => :destroy # Editors can create but not destroy 
  </code>
</pre>

  Roles access can be mixed and matched
<pre>
  <code>
    class MixedRoleAccessController < ApplicationController

      # Content Editor can only access the "new" action
      grant_access_to :content_editor, :only => [:new, :create]

      # Admin has access to only "destroy" but not "new", "publish" or "create"
      grant_access_to :admin,   :only => [:destroy]

      # Editor has access to "new", "publish" and "create" but not "destroy"
      grant_access_to :editor,  :except => :destroy

      def new;end
      def create;end
      def publish;end
      def destroy;end
    end
  </code>
</pre>

  You can also route around roles for entire controllers like this:
<pre>
  <code>
    class PublicController < AdminOnlyController
      skip_role_system
    end
  </code>
</pre>

  Or you can designate certain actions public and certain actions role-required
  <pre>
    <code>
      class MixedAuthenticatedNonAuthenticatedActionsController < MockApplicationController
        all_access_to :only => [:everybody_allowed]
        grant_access_to [:admin]
        def admin_only;end
        def everybody_allowed;end
      end
    </code>
  </pre>

h2. Valid Options

* :only - Only require the role for a specific actions
* :except - The role is required for all but the specificed action(s)
* :if - A Proc or string to evaluate; a result of true means the role is required.
* :unless - The opposite of if

{'fraction_non_alphanumeric': 0.08162839248434238, 'fraction_numerical': 0.0012526096033402922, 'mean_word_length': 3.3753424657534246, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6292215', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1319, 'n_words': 586}