mongoid_ability 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid_ability/accessible_query_builder.rb +16 -6
- data/lib/mongoid_ability/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c507aee422f260d41b3362fdaab309fcaaec4b6d
|
4
|
+
data.tar.gz: 64cfd77de7d1498dde919e10e3639c7d8be4d668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 719e74564b155969eb8873e216e52c85756b82ccbc04573dda5b4ea66c80138c7e1596325daa51dfc15495b3e528db1602ad3c89eea5485170d45cb8bb5df27c
|
7
|
+
data.tar.gz: bebec4577d5ef119322b2c9ac30b83a42cd4dc73fd62b0faabd95e686c212741420f0e19eaf964991008c7aba39488534f47bf8ec573e7d22f390e287f6a09fc
|
@@ -7,24 +7,34 @@ module MongoidAbility
|
|
7
7
|
# =====================================================================
|
8
8
|
|
9
9
|
def call
|
10
|
-
|
11
|
-
base_class.criteria.where(
|
10
|
+
return base_class.criteria unless and_conditions.present?
|
11
|
+
base_class.criteria.where(and_conditions)
|
12
12
|
end
|
13
13
|
|
14
14
|
private # =============================================================
|
15
15
|
|
16
|
+
def or_conditions
|
17
|
+
return unless conditions = [closed_types_condition, open_ids_condition].compact.presence
|
18
|
+
{ :$or => conditions }
|
19
|
+
end
|
20
|
+
|
21
|
+
def and_conditions
|
22
|
+
return unless conditions = [or_conditions, closed_ids_condition].compact.presence
|
23
|
+
{ :$and => conditions }
|
24
|
+
end
|
25
|
+
|
16
26
|
def closed_types_condition
|
27
|
+
return unless values.closed_types.present?
|
17
28
|
{ :_type.nin => values.closed_types }
|
18
29
|
end
|
19
30
|
|
20
31
|
def open_ids_condition
|
21
|
-
|
22
|
-
|
23
|
-
:_id.in => values.open_types_and_ids.map(&:id)
|
24
|
-
}
|
32
|
+
return unless values.open_types_and_ids.present?
|
33
|
+
{ :_id.in => values.open_types_and_ids.map(&:id) }
|
25
34
|
end
|
26
35
|
|
27
36
|
def closed_ids_condition
|
37
|
+
return unless values.closed_ids.present?
|
28
38
|
{ :_id.nin => values.closed_ids }
|
29
39
|
end
|
30
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_ability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cancancan
|