<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-Copyright (c) 2008 RoleSystem Mark Daggett
+Copyright (c) 2009 RoleSystem Mark Daggett
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the</diff>
      <filename>MIT-LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,18 @@
-module RoleSystem  
+module RoleSystem
   class RoleRequired &lt; StandardError; end
   class NoRolePlayer &lt; StandardError; end
-  
+
   def self.included(base)
     base.send :class_inheritable_array, :role_requirements, :public_actions, :private_actions
+    base.send :class_inheritable_accessor, :skipping_role_system
+    base.send :skipping_role_system=, false
     base.send :include, InstanceMethods
     base.send :extend, ClassMethods
     base.send :role_requirements=, []
     base.send :public_actions=, []
     base.send :private_actions=, []
   end
-  
+
   # The RoleSystem is a controller mixin to grant or restrict access to actions based on the
   # roles a user belongs to.
   #
@@ -30,7 +32,15 @@ module RoleSystem
   #    grant_access_to :editor,  :except =&gt; :destroy
   #  end
   module ClassMethods
-    
+
+    # Use this action when you want to skip role checking all together.
+    # This is useful for example if you have a public controller inside an admin namespace
+    # which inherits from an AdminController that specifies a default role.
+    def skip_role_system
+      self.skipping_role_system = true
+      @roles_checked = true
+    end
+
     # These actions don't require roles at all. This method is helpful for instances
     # where some actions are public, while others require a role.
     def all_access_to(options = {})
@@ -42,7 +52,7 @@ module RoleSystem
         self.private_actions = [options[:except]].flatten.compact.collect{ |a| a.to_sym }
       end
     end
-    
+
     # This method restricts or grants access to actions based on a user's role list.
     def grant_access_to(roles, options = {})
       roles = [roles].flatten
@@ -62,23 +72,24 @@ module RoleSystem
       self.role_requirements &lt;&lt; { :roles =&gt; roles, :options =&gt; options }
     end
   end
-  
+
   module InstanceMethods
-    
+
     def self.included(base)
       def role_player=(param)
         @role_player = param.to_sym
       end
-      
+
       private
       def check_roles
+        return true if self.skipping_role_system
         return true if no_roles_required_for(binding)
         raise RoleSystem::RoleRequired unless @role_player
         user = self.send(@role_player)
         raise RoleSystem::RoleRequired unless has_required_roles?(user, binding)
         true
       rescue RoleSystem::RoleRequired, NoMethodError
-        
+
         # restful_authentication users access_denied so if the controller already has
         # this installed then use this method.
         if self.methods.include?('access_denied')
@@ -95,11 +106,11 @@ module RoleSystem
           public_action = self.public_actions.include?(params[:action].to_sym)
         end
         unless self.private_actions.empty?
-          public_action = !self.private_actions.include?(params[:action].to_sym) 
+          public_action = !self.private_actions.include?(params[:action].to_sym)
         end
         public_action
       end
-      
+
       # This method iterates over all of the role requirements supplied by the controler
       # and determines if the account holder has the needed roles to access requested action.
       # An example role requirement array might looke like:
@@ -118,28 +129,28 @@ module RoleSystem
           roles = role_requirement[:roles]
           options = role_requirement[:options]
           params[:action] = (params[:action]||&quot;index&quot;).to_sym
-          
+
           next unless access_to_action?(options)
           if options.has_key?(:if)
-            
+
             # If the proc evaluates false then it doesn't matter if they have the required role
             # because it was only permissible during this conditional access.
             @failed_proc = true unless (String===options[:if] ? eval(options[:if], binding) : options[:if].call(params))
           end
 
           if options.has_key?(:unless)
-            
-            # If this proc evaluates true then restrict access to this action because their 
+
+            # If this proc evaluates true then restrict access to this action because their
             # access was provisional for conditions where this proc would fail.
             @failed_proc = true if ( String===options[:unless] ? eval(options[:unless], binding) : options[:unless].call(params) )
           end
-          
+
           roles.each { |role| @access_granted = true if user.has_role?(role) } unless @failed_proc
           return true if @access_granted
         end
         @access_granted
       end
-      
+
       protected
       def access_to_action?(options)
         if options.has_key?(:only)</diff>
      <filename>lib/role_system.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@ class MockMember
   def roles
     @roles
   end
-  
+
   def has_role?(role)
     @roles.map{ |g| g.name.downcase.to_sym }.include?(role)
   end
@@ -16,11 +16,11 @@ end
 # This controller simulates a controller that includes AuthenticatedSystem, which the 
 # role system can hook into.
 class MockApplicationController &lt; ActionController::Base
-  
+
   # Used by the RoleSystem to find the current member (if any)
   # This before filter needs to be called BEFORE any role checking.
   before_filter { |controller| controller.role_player = :current_member }
-  
+
   def access_denied
     redirect_to new_sessions_path and return false
   end
@@ -32,18 +32,18 @@ module RoleSystemSpecHelper
     @admin_role = mock_model(Group, :name =&gt; 'admin', :context =&gt; 'role')
     @content_editor_role = mock_model(Group, :name =&gt; 'content_editor', :context =&gt; 'role')
   end
-  
+
   def login_as(role)
     instance_variable_set(&quot;@#{role}&quot;.to_sym, MockMember.new(:roles =&gt; [instance_variable_get(&quot;@#{role}_role&quot;)]))
     @controller.stub!(:current_member).and_return(instance_variable_get(&quot;@#{role}&quot;))
-  end  
+  end
 end
 
 class AdminOnlyController &lt; MockApplicationController
   grant_access_to :admin
-  
+
   def index
-  end  
+  end
 end
 
 describe RoleSystem, &quot;a controller allowing only admin access&quot;, :type =&gt; :controller do
@@ -52,13 +52,13 @@ describe RoleSystem, &quot;a controller allowing only admin access&quot;, :type =&gt; :contro
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should allow an admin access&quot; do
     login_as('admin')
     get :index
     response.should be_success
   end
-  
+
   it &quot;should prevent access by anyone who is not an admin&quot; do
     login_as('editor')
     get :index
@@ -66,14 +66,23 @@ describe RoleSystem, &quot;a controller allowing only admin access&quot;, :type =&gt; :contro
   end
 end
 
+class PublicController &lt; AdminOnlyController
+  skip_role_system
+end
+
+describe RoleSystem, &quot;a controller skipping the role system of an inherited controller&quot; do
+  get :index
+  response.should be_success
+end
+
 class MixedRoleAccessController &lt; MockApplicationController
   grant_access_to :content_editor, :only =&gt; :new
   grant_access_to :admin,   :only =&gt; [:new, :destroy]
   grant_access_to :editor,  :except =&gt; :destroy
-  
+
   def index;end
   def new;end
-  def destroy;end  
+  def destroy;end
 end
 
 describe RoleSystem, &quot;a controller allowing access to actions by role&quot;, :type =&gt; :controller do
@@ -82,33 +91,33 @@ describe RoleSystem, &quot;a controller allowing access to actions by role&quot;, :type =&gt;
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should grant access to content_editor and admin for new&quot; do
     login_as('content_editor')
     get :new
     response.should be_success
-    
+
     login_as('admin')
     get :new
     response.should be_success
   end
-  
+
   it &quot;should grant acccess to editor for index&quot; do
     login_as('editor')
     get :index
     response.should be_success
   end
-  
-  it &quot;should only give destroy access to admin&quot; do   
+
+  it &quot;should only give destroy access to admin&quot; do
     login_as('editor')
     get :destroy
     response.should redirect_to(new_sessions_path)
-    
+
     login_as('admin')
     get :destroy
     response.should be_success
   end
-  
+
   it &quot;should not give access to index to admin&quot; do
     login_as('admin')
     get :index
@@ -117,10 +126,9 @@ describe RoleSystem, &quot;a controller allowing access to actions by role&quot;, :type =&gt;
 end
 
 class ConditionalAccessController &lt; MockApplicationController
-
   grant_access_to :content_editor, :if =&gt; Proc.new { |controller| controller.has_key?(:sekret) }
   grant_access_to :admin, :unless =&gt; Proc.new { |controller| controller.has_key?(:admin_sekret) }
-  
+
   def index;end
 end
 
@@ -130,7 +138,7 @@ describe RoleSystem, &quot;a controller allowing access under certain conditions&quot;, :t
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should grant access to admin unless access is revoked ahead of time&quot; do
     login_as('admin')
     get :index
@@ -139,12 +147,12 @@ describe RoleSystem, &quot;a controller allowing access under certain conditions&quot;, :t
     get :index, :admin_sekret =&gt; 'shhhhhhhhhhhhhhh'
     response.should redirect_to(new_sessions_path)
   end
-  
+
   it &quot;should allow access to content_editors if special access is granted&quot; do
     login_as('content_editor')
     get :index
     response.should redirect_to(new_sessions_path)
-    
+
     get :index, :sekret =&gt; 'shhhhhhhhhhhhhhh'
     response.should be_success
   end
@@ -153,7 +161,7 @@ end
 class EquivalentAccessController &lt; MockApplicationController
   grant_access_to :admin
   grant_access_to [:content_editor, :editor] , :only =&gt; :index
-  
+
   def index;end
   def new;end
 end
@@ -164,26 +172,26 @@ describe RoleSystem, &quot;a controller where two roles are equivalent&quot;, :type =&gt; :co
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should treat the roles identically&quot; do
     login_as('admin')
     get :index
     response.should be_success
-    
+
     get :new
     response.should be_success
-    
+
     login_as('editor')
     get :index
     response.should be_success
-    
+
     get :new
     response.should redirect_to(new_sessions_path)
 
     login_as('content_editor')
     get :index
     response.should be_success
-    
+
     get :new
     response.should redirect_to(new_sessions_path)
   end
@@ -202,7 +210,7 @@ describe RoleSystem, &quot;a controller without authenticated system&quot;, :type =&gt; :cont
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should just return an access denied header when authenticated_system is not available&quot; do
     login_as('editor')
     get :index
@@ -223,29 +231,29 @@ describe RoleSystem, &quot;a controller where only certain actions require roles&quot;, :t
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should allow a member with a role to access both role-requried and public actions&quot; do
     login_as('admin')
     get :admin_only
     response.should be_success
-    
+
     get :everybody_allowed
     response.should be_success
   end
-  
+
   it &quot;should allow members without a role or without being logged in to access public actions&quot; do
-    
+
     # No session at all
     get :admin_only
     response.should redirect_to(new_sessions_path)
-    
+
     get :everybody_allowed
     response.should be_success
-    
+
     login_as('editor')
     get :admin_only
     response.should redirect_to(new_sessions_path)
-    
+
     get :everybody_allowed
     response.should be_success
   end
@@ -264,29 +272,29 @@ describe RoleSystem, &quot;another controller where only certain actions require role
   before(:each) do
     add_roles
   end
-  
+
   it &quot;should allow a member with a role to access both role-requried and public actions&quot; do
     login_as('admin')
     get :everybody_allowed
     response.should be_success
-    
+
     get :nobody_allowed
     response.should be_success
   end
-  
+
   it &quot;should allow members without a role or without being logged in to access public actions&quot; do
-    
+
     # No session at all
     get :nobody_allowed
     response.should redirect_to(new_sessions_path)
-    
+
     get :everybody_allowed
     response.should be_success
-    
+
     login_as('editor')
     get :nobody_allowed
     response.should redirect_to(new_sessions_path)
-    
+
     get :everybody_allowed
     response.should be_success
   end</diff>
      <filename>spec/role_system_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ba6b27658f27ccdcc7c005dd1cbd161e7091fdb6</id>
    </parent>
  </parents>
  <author>
    <name>Mark Daggett</name>
    <email>heavysixer@heavysixer.local</email>
  </author>
  <url>http://github.com/heavysixer/rolesystem/commit/f6747802eb687b89c26d6651867c2bdee61792e3</url>
  <id>f6747802eb687b89c26d6651867c2bdee61792e3</id>
  <committed-date>2009-06-25T08:28:24-07:00</committed-date>
  <authored-date>2009-06-25T08:28:24-07:00</authored-date>
  <message>updating the role_system with the ability to skip role checking all together for specific controllers that inherit from a base controller that uses role_system.</message>
  <tree>320f3ae1b4513d87eb210d67d8411cd7020f1117</tree>
  <committer>
    <name>Mark Daggett</name>
    <email>heavysixer@heavysixer.local</email>
  </committer>
</commit>
