Skip to content
Browse files

Return empty set early if no can rules are present.

Thanks dkubb!
  • Loading branch information...
1 parent d6851de commit 16bdb8d42eb03ff435bdadaff70c5307064304c2 @emmanuel emmanuel committed
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/cancan/model_adapters/data_mapper_adapter.rb
View
1 lib/cancan/model_adapters/data_mapper_adapter.rb
@@ -17,6 +17,7 @@ def self.matches_conditions_hash?(subject, conditions)
def database_records
scope = @model_class.all(:conditions => ["0 = 1"])
cans, cannots = @rules.partition { |r| r.base_behavior }
+ return scope if cans.empty?
# apply unions first, then differences. this mean cannot overrides can
cans.each { |r| scope += @model_class.all(:conditions => r.conditions) }
cannots.each { |r| scope -= @model_class.all(:conditions => r.conditions) }

0 comments on commit 16bdb8d

Please sign in to comment.
Something went wrong with that request. Please try again.