diff --git a/lib/cancan/can_definition.rb b/lib/cancan/can_definition.rb index ed1dfa9..e61dd94 100644 --- a/lib/cancan/can_definition.rb +++ b/lib/cancan/can_definition.rb @@ -26,7 +26,7 @@ module CanCan # Matches the block or conditions hash def matches_conditions?(action, subject, extra_args) if @block && subject.class != Class - call_block(action, subject, extra_args) + @block.call(subject, *extra_args) elsif @conditions.kind_of?(Hash) && subject.class != Class matches_conditions_hash?(subject) else @@ -91,13 +91,5 @@ module CanCan end end end - - def call_block(action, subject, extra_args) - block_args = [] - block_args << action if @expanded_actions.include?(:manage) - block_args << (subject.class == Class ? nil : subject) - block_args += extra_args - @block.call(*block_args) - end end end diff --git a/spec/cancan/ability_spec.rb b/spec/cancan/ability_spec.rb index ac3e03a..e23c7a3 100644 --- a/spec/cancan/ability_spec.rb +++ b/spec/cancan/ability_spec.rb @@ -56,9 +56,8 @@ describe CanCan::Ability do @block_called.should be_false end - it "should pass action and object for global manage actions" do - @ability.can :manage, Array do |action, object| - action.should == :stuff + it "should pass only object for global manage actions" do + @ability.can :manage, Array do |object| object.should == [1, 2] @block_called = true end @@ -80,9 +79,8 @@ describe CanCan::Ability do @ability.can?(:increment, 123).should be_true end - it "should return block result for action, object_class, and object for any action" do - @ability.can :manage, :all do |action, object| - action.should == :foo + it "should return block result and only pass object for any action" do + @ability.can :manage, :all do |object| object.should == 123 @block_called = true end