<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,7 @@
+* Fix namespaced models in roles backend (thanks goes to Tomas Jogin)
+* Action name override in boolean methods.
+* @:query_method@ option for @access_control@.
+
 h2. 0.10.0 (03-May-2009)
 
 * Use context+matchy combo for testing</diff>
      <filename>CHANGELOG.textile</filename>
    </modified>
    <modified>
      <diff>@@ -45,12 +45,13 @@ module Acl9
         end
 
         method = opts[:as_method]
-        query_method = opts[:query_method]
 
+        query_method_available = true
         generator = case
                     when method &amp;&amp; filter
-                      Acl9::Dsl::Generators::FilterMethod.new(subject_method, method, query_method)
+                      Acl9::Dsl::Generators::FilterMethod.new(subject_method, method)
                     when method &amp;&amp; !filter
+                      query_method_available = false
                       Acl9::Dsl::Generators::BooleanMethod.new(subject_method, method)
                     else
                       Acl9::Dsl::Generators::FilterLambda.new(subject_method)
@@ -59,6 +60,25 @@ module Acl9
         generator.acl_block!(&amp;block)
 
         generator.install_on(self, opts)
+
+        if query_method_available &amp;&amp; (query_method = opts.delete(:query_method))
+          case query_method
+          when true
+            if method
+              query_method = &quot;#{method}?&quot;
+            else
+              raise ArgumentError, &quot;You must specify :query_method as Symbol&quot;
+            end
+          when Symbol, String
+            # okay here
+          else
+            raise ArgumentError, &quot;Invalid value for :query_method&quot;
+          end
+
+          second_generator = Acl9::Dsl::Generators::BooleanMethod.new(subject_method, query_method)
+          second_generator.acl_block!(&amp;block)
+          second_generator.install_on(self, opts)
+        end
       end
     end
   end</diff>
      <filename>lib/acl9/controller_extensions.rb</filename>
    </modified>
    <modified>
      <diff>@@ -114,12 +114,11 @@ module Acl9
       ################################################################
 
       class FilterMethod &lt; BaseGenerator
-        def initialize(subject_method, method_name, query_meth = nil)
+        def initialize(subject_method, method_name)
           super
 
           @method_name = method_name
           @controller = nil
-          @query_method = (query_meth == true) ? &quot;#{method_name}?&quot; : query_meth
         end
 
         def install_on(controller_class, options)
@@ -138,24 +137,13 @@ module Acl9
         end
 
         def to_method_code
-          code = &lt;&lt;-RUBY
+          &lt;&lt;-RUBY
             def #{@method_name}
               unless #{allowance_expression}
                 #{_access_denied}
               end
             end
           RUBY
-
-          if @query_method
-            code += &lt;&lt;-RUBY
-              def #{@query_method}(action)
-                action_name = action.to_s
-                return #{allowance_expression}
-              end
-            RUBY
-          end
-
-          code
         end
       end
 
@@ -176,8 +164,16 @@ module Acl9
 
         def to_method_code
           &lt;&lt;-RUBY
-            def #{@method_name}(options = {})
-              #{allowance_expression}
+            def #{@method_name}(*args)
+              options = args.extract_options!
+
+              unless args.size &lt;= 1
+                raise ArgumentError, &quot;call #{@method_name} with 0, 1 or 2 arguments&quot;
+              end
+
+              action_name = args.empty? ? self.action_name : args.first.to_s
+
+              return #{allowance_expression}
             end
           RUBY
         end</diff>
      <filename>lib/acl9/controller_extensions/generators.rb</filename>
    </modified>
    <modified>
      <diff>@@ -160,6 +160,32 @@ class ACLObjectsHashTest &lt; ActionController::TestCase
   end
 end
 
+class ACLActionOverrideTest &lt; ActionController::TestCase
+  tests ACLActionOverride
+
+  it &quot;should allow index action to anonymous&quot; do
+    get :check_allow, :_action =&gt; :index
+    @response.body.should == 'OK'
+  end
+
+  it &quot;should deny show action to anonymous&quot; do
+    get :check_allow, :_action =&gt; :show
+    @response.body.should == 'AccessDenied'
+  end
+
+  it &quot;should deny edit action to regular user&quot; do
+    get :check_allow_with_foo, :_action =&gt; :edit, :user =&gt; TheOnlyUser.instance
+
+    @response.body.should == 'AccessDenied'
+  end
+
+  it &quot;should allow edit action to owner of foo&quot; do
+    get :check_allow_with_foo, :_action =&gt; :edit, :user =&gt; OwnerOfFoo.new
+
+    @response.body.should == 'OK'
+  end
+end
+
 class ACLHelperMethodTest &lt; ActionController::TestCase
   tests ACLHelperMethod
 
@@ -183,6 +209,7 @@ module ACLQueryMixin
         before do
           @editor = Beholder.new(:editor)
           @viewer = Beholder.new(:viewer)
+          @owneroffoo = OwnerOfFoo.new
         end
 
         [:edit, :update, :destroy].each do |meth|
@@ -212,6 +239,16 @@ module ACLQueryMixin
             @controller.acl?(meth.to_s).should == true
           end
         end
+
+        it &quot;should return false for editor/fooize&quot; do
+          @controller.current_user = @editor
+          @controller.acl?(:fooize).should == false
+        end
+
+        it &quot;should return true for foo owner&quot; do
+          @controller.current_user = @owneroffoo
+          @controller.acl?(:fooize, :foo =&gt; MyDearFoo.instance).should == true
+        end
       end
     end
   end
@@ -221,7 +258,17 @@ class ACLQueryMethodTest &lt; ActionController::TestCase
   tests ACLQueryMethod
 
   it &quot;should respond to :acl?&quot; do
-    @controller.should respond_to(:acl)
+    @controller.should respond_to(:acl?)
+  end
+
+  include ACLQueryMixin
+end
+
+class ACLQueryMethodWithLambdaTest &lt; ActionController::TestCase
+  tests ACLQueryMethodWithLambda
+
+  it &quot;should respond to :acl?&quot; do
+    @controller.should respond_to(:acl?)
   end
 
   include ACLQueryMixin</diff>
      <filename>test/access_control_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -55,7 +55,7 @@ class ACLArguments &lt; EmptyController
   access_control :except =&gt; [:index, :show] do
     allow :admin, :if =&gt; :true_meth, :unless =&gt; :false_meth
   end
-  
+
   include TrueFalse
 end
 
@@ -129,12 +129,33 @@ class ACLObjectsHash &lt; ApplicationController
     @foo = nil
     render :text =&gt; (allowed?(:foo =&gt; MyDearFoo.instance) ? 'OK' : 'AccessDenied')
   end
-  
+
+  def current_user
+    params[:user]
+  end
+end
+
+class ACLActionOverride &lt; ApplicationController
+  access_control :allowed?, :filter =&gt; false do
+    allow all, :to =&gt; :index
+    deny all, :to =&gt; :show
+    allow :owner, :of =&gt; :foo, :to =&gt; :edit
+  end
+
+  def check_allow
+    render :text =&gt; (allowed?(params[:_action]) ? 'OK' : 'AccessDenied')
+  end
+
+  def check_allow_with_foo
+    render :text =&gt; (allowed?(params[:_action], :foo =&gt; MyDearFoo.instance) ? 'OK' : 'AccessDenied')
+  end
+
   def current_user
     params[:user]
   end
 end
 
+
 class ACLHelperMethod &lt; ApplicationController
   access_control :helper =&gt; :foo? do
     allow :owner, :of =&gt; :foo
@@ -157,6 +178,17 @@ class ACLQueryMethod &lt; ApplicationController
   access_control :acl, :query_method =&gt; true do
     allow :editor, :to =&gt; [:edit, :update, :destroy]
     allow :viewer, :to =&gt; [:index, :show]
+    allow :owner,  :of =&gt; :foo, :to =&gt; :fooize
+  end
+end
+
+class ACLQueryMethodWithLambda &lt; ApplicationController
+  attr_accessor :current_user
+
+  access_control :query_method =&gt; :acl? do
+    allow :editor, :to =&gt; [:edit, :update, :destroy]
+    allow :viewer, :to =&gt; [:index, :show]
+    allow :owner,  :of =&gt; :foo, :to =&gt; :fooize
   end
 end
 
@@ -166,6 +198,7 @@ class ACLNamedQueryMethod &lt; ApplicationController
   access_control :acl, :query_method =&gt; 'allow_ay' do
     allow :editor, :to =&gt; [:edit, :update, :destroy]
     allow :viewer, :to =&gt; [:index, :show]
+    allow :owner,  :of =&gt; :foo, :to =&gt; :fooize
   end
 
   def acl?(*args)</diff>
      <filename>test/support/controllers.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>73fe443e41adf91263c9318b32597ed89505bdb3</id>
    </parent>
  </parents>
  <author>
    <name>oleg dashevskii</name>
    <email>be9@be9.ru</email>
  </author>
  <url>http://github.com/be9/acl9/commit/00f30940fa98fe138a68f8a793679f297fb0bd80</url>
  <id>00f30940fa98fe138a68f8a793679f297fb0bd80</id>
  <committed-date>2009-06-24T22:25:09-07:00</committed-date>
  <authored-date>2009-06-24T22:25:09-07:00</authored-date>
  <message>Redo :query_method with extending BooleanMethod generator.

Now it's supported in both method and lambda cases and can look into the
passed hash for objects.

Side-effect: all boolean methods now support action override!
Pass it as the optional first argument.</message>
  <tree>d7028eac010275fa82004dec3fb9f017cead70f9</tree>
  <committer>
    <name>oleg dashevskii</name>
    <email>be9@be9.ru</email>
  </committer>
</commit>
