Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Return empty set early if no can rules are present.

Thanks dkubb!
  • Loading branch information...
commit 16bdb8d42eb03ff435bdadaff70c5307064304c2 1 parent d6851de
@emmanuel emmanuel authored
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) }
Please sign in to comment.
Something went wrong with that request. Please try again.