Class: CanCan::ModelAdapters::MongoidAdapter
Class Method Summary
collapse
Instance Method Summary
collapse
adapter_class, inherited, #initialize, matches_condition?, override_condition_matching?
Class Method Details
.for_class?(model_class) ⇒ Boolean
4
5
6
|
# File 'lib/cancan/model_adapters/mongoid_adapter.rb', line 4
def self.for_class?(model_class)
model_class <= Mongoid::Document
end
|
.matches_conditions_hash?(subject, conditions) ⇒ Boolean
12
13
14
15
16
|
# File 'lib/cancan/model_adapters/mongoid_adapter.rb', line 12
def self.matches_conditions_hash?(subject, conditions)
subject.matches?( subject.class.where(conditions).selector )
end
|
.override_conditions_hash_matching?(subject, conditions) ⇒ Boolean
8
9
10
|
# File 'lib/cancan/model_adapters/mongoid_adapter.rb', line 8
def self.override_conditions_hash_matching?(subject, conditions)
conditions.any? { |k,v| !k.kind_of?(Symbol) }
end
|
Instance Method Details
#database_records ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/cancan/model_adapters/mongoid_adapter.rb', line 18
def database_records
if @rules.size == 0
@model_class.where(:_id => {'$exists' => false, '$type' => 7}) else
@rules.inject(@model_class.all) do |records, rule|
if rule.base_behavior
records.or(rule.conditions)
else
records.excludes(rule.conditions)
end
end
end
end
|