mongoid_ability 0.3.0 → 0.3.1
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/lock.rb +4 -1
- 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: 6fb77bedd14bcfb7ebb1273b4ef828ff32bad598
|
4
|
+
data.tar.gz: 64be0c5963ed532e20fe346c11ac7b2e8c8e1597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6c8e052c01530819e06b298bfb9e8cb49bb225c853c157a3789e07f4f722a06f4a24f9a129bf21194cf48a913637033c2b22efb499a3a73193ba5e0e06f758
|
7
|
+
data.tar.gz: 85c46d10706e25f424138cc5645d6030aa97446e8a3b430ecd6ef751c13102671c098d9605f74f624f4c4cb5bd46a6f4cf4a6f05ca1d0ef4ca6e45b5b4c96c56
|
data/lib/mongoid_ability/lock.rb
CHANGED
@@ -19,7 +19,10 @@ module MongoidAbility
|
|
19
19
|
|
20
20
|
scope :for_subject_type, -> (subject_type) { where(subject_type: subject_type.to_s) }
|
21
21
|
scope :for_subject_id, -> (subject_id) { where(subject_id: subject_id.presence) }
|
22
|
-
scope :for_subject, -> (subject) {
|
22
|
+
scope :for_subject, -> (subject) {
|
23
|
+
return where(subject_id: nil) unless subject.present?
|
24
|
+
where(subject_type: subject.class.model_name, subject_id: subject.id)
|
25
|
+
}
|
23
26
|
|
24
27
|
scope :class_locks, -> { where(subject_id: nil) }
|
25
28
|
scope :id_locks, -> { ne(subject_id: nil) }
|
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.1
|
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-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cancancan
|