improving DataMapper adapter and specs

This commit is contained in:
Ryan Bates
2011-01-05 13:22:06 -08:00
parent cef6c21232
commit 15ca8ade3b
5 changed files with 102 additions and 43 deletions

View File

@@ -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

View File

@@ -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