mongoid_ability 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mongoid_ability/accessible_query_builder.rb +10 -6
- data/lib/mongoid_ability/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cececf7c6d06e78a0352d1d25585e9015da3435
|
4
|
+
data.tar.gz: 3c2c4e2bf689af0ff65b39c9e6756aca7fba1261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4158f26b3ee625ecbac3eee508a8ff310cd35232d9f4af8ae6d7e15e051ca49174a12ddaa279e4bfd785163a7405449e9a14d7fb038685219153b3db2982413
|
7
|
+
data.tar.gz: 11d07ad4dc0b89615ccafb366623a2e756deca09d27b5e194d0344684936906762bd39fadb1e9e35ce235a0bd643fc9fe30e1a683839ece649e501ac22b89e60
|
@@ -8,21 +8,25 @@ module MongoidAbility
|
|
8
8
|
|
9
9
|
def call
|
10
10
|
return base_class.criteria unless and_conditions.present?
|
11
|
-
base_class.criteria.where(
|
11
|
+
base_class.criteria.where(conditions)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
def or_conditions
|
17
|
-
return unless conditions = [closed_types_condition, open_ids_condition].compact.presence
|
18
|
-
{ :$or => conditions }
|
14
|
+
def conditions
|
15
|
+
and_conditions
|
19
16
|
end
|
20
17
|
|
18
|
+
private # =============================================================
|
19
|
+
|
21
20
|
def and_conditions
|
22
21
|
return unless conditions = [or_conditions, closed_ids_condition].compact.presence
|
23
22
|
{ :$and => conditions }
|
24
23
|
end
|
25
24
|
|
25
|
+
def or_conditions
|
26
|
+
return unless conditions = [closed_types_condition, open_ids_condition].compact.presence
|
27
|
+
{ :$or => conditions }
|
28
|
+
end
|
29
|
+
|
26
30
|
def closed_types_condition
|
27
31
|
return unless values.closed_types.present?
|
28
32
|
{ :_type.nin => values.closed_types }
|