improving DataMapper adapter and specs
This commit is contained in:
@@ -5,8 +5,16 @@ module CanCan
|
||||
model_class <= DataMapper::Resource
|
||||
end
|
||||
|
||||
def self.override_conditions_hash_matching?(subject, conditions)
|
||||
conditions.any? { |k,v| !k.kind_of?(Symbol) }
|
||||
end
|
||||
|
||||
def self.matches_conditions_hash?(subject, conditions)
|
||||
subject.class.all(:conditions => conditions).include?(subject) # TODO don't use a database query here for performance and other instances
|
||||
end
|
||||
|
||||
def database_records
|
||||
scope = @model_class.all(:conditions => ['true=false'])
|
||||
scope = @model_class.all(:conditions => ["0=1"])
|
||||
conditions.each do |condition|
|
||||
scope += @model_class.all(:conditions => condition)
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ module CanCan
|
||||
end
|
||||
|
||||
def self.matches_conditions_hash?(subject, conditions)
|
||||
subject.class.where(conditions).include?(subject) # just use Mongoid's where function
|
||||
subject.class.where(conditions).include?(subject) # TODO don't use a database query here for performance and other instances
|
||||
end
|
||||
|
||||
def database_records
|
||||
|
||||
Reference in New Issue
Block a user