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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f894c51e60acf940ca8b92ec9f7402df3b852bf9
4
- data.tar.gz: d923b2dfee15aee43d0aab8535adbd4ad44ff6f2
3
+ metadata.gz: 6fb77bedd14bcfb7ebb1273b4ef828ff32bad598
4
+ data.tar.gz: 64be0c5963ed532e20fe346c11ac7b2e8c8e1597
5
5
  SHA512:
6
- metadata.gz: 5a004c82655f15430cbb9421a3180a35d72375687f5301bb0fffd8b373055b87dd15ee9e187db4cd321ef7bede86c525f7a600030d088fdb31b019c654c51098
7
- data.tar.gz: d8336fcfbb6a4f1ca8ede3e970dae45406b9cd575c83a78e5c48fda2ef02d6274ab06d218839ebe13b8a5c7ba71a121e40e2b2875ae074b5ee8d5f63a1d080c2
6
+ metadata.gz: 9d6c8e052c01530819e06b298bfb9e8cb49bb225c853c157a3789e07f4f722a06f4a24f9a129bf21194cf48a913637033c2b22efb499a3a73193ba5e0e06f758
7
+ data.tar.gz: 85c46d10706e25f424138cc5645d6030aa97446e8a3b430ecd6ef751c13102671c098d9605f74f624f4c4cb5bd46a6f4cf4a6f05ca1d0ef4ca6e45b5b4c96c56
@@ -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) { where(subject_type: subject.class.model_name, subject_id: subject.id) }
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) }
@@ -1,3 +1,3 @@
1
1
  module MongoidAbility
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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-19 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cancancan