mongoid_ability 2.0.3 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/mongoid_ability/lock.rb +5 -1
- data/lib/mongoid_ability/owner.rb +2 -0
- data/lib/mongoid_ability/subject.rb +2 -0
- data/lib/mongoid_ability/version.rb +1 -1
- data/mongoid_ability.gemspec +1 -1
- data/test/mongoid_ability/owner_test.rb +1 -1
- data/test/support/test_classes/my_lock.rb +6 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a0e978ec258c3a3b3e93fa34b6943c8af6b09666722b0ac2b61f196fa972394
|
4
|
+
data.tar.gz: 132f93b4885b86db918c22739859944b86d98e83a07fd7f90ac0e259b5d6e901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50b463ff75c3ecf23a1187b05fcba527c4b50bd47e3c4831d7aece79124b366194d28da44af3acb414f4d0a8de8c02799a24e321a138bab1046552463f7b8a4e
|
7
|
+
data.tar.gz: 06dee8bd65eacce1939aca16d3f6b001b7ed58e708f776903eeb3a2bd4873cf1a3d8d09e5a817590571113d29795b038ec979cacd6f243f43f18d07084d2efab
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/mongoid_ability/lock.rb
CHANGED
@@ -9,7 +9,11 @@ module MongoidAbility
|
|
9
9
|
field :outcome, type: Boolean, default: false
|
10
10
|
field :opts, as: :options, type: Hash, default: {}
|
11
11
|
|
12
|
-
belongs_to :subject, polymorphic: true,
|
12
|
+
belongs_to :subject, polymorphic: true, optional: true
|
13
|
+
# Mongoid 7 does not support `touch: true` on polymorphic associations
|
14
|
+
after_save -> { subject.touch if subject? }
|
15
|
+
after_destroy -> { subject.touch if subject? }
|
16
|
+
after_touch -> { subject.touch if subject? }
|
13
17
|
|
14
18
|
# TODO: validate that action is defined on subject or its superclasses
|
15
19
|
validates :action, presence: true, uniqueness: { scope: [:subject_type, :subject_id, :outcome] }
|
@@ -3,6 +3,8 @@ module MongoidAbility
|
|
3
3
|
def self.included(base)
|
4
4
|
base.extend ClassMethods
|
5
5
|
base.class_eval do
|
6
|
+
include Mongoid::Touchable::InstanceMethods
|
7
|
+
|
6
8
|
# always set the _type field as it is used by :accessible_by queries
|
7
9
|
field :_type, type: String, default: model_name
|
8
10
|
end
|
data/mongoid_ability.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'cancancan', '~> 2.2'
|
22
|
-
spec.add_dependency 'mongoid', '
|
22
|
+
spec.add_dependency 'mongoid', '~> 7.0', '>= 7.0.2'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler'
|
25
25
|
spec.add_development_dependency 'coveralls'
|
@@ -17,7 +17,7 @@ module MongoidAbility
|
|
17
17
|
|
18
18
|
describe 'locks relation' do
|
19
19
|
it { subject.class.locks_relation_name.must_equal :my_locks }
|
20
|
-
it { subject.
|
20
|
+
it { subject.reflect_on_association(:my_locks).name.must_equal :my_locks }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -3,7 +3,12 @@ class MyLock
|
|
3
3
|
include Mongoid::Timestamps
|
4
4
|
include MongoidAbility::Lock
|
5
5
|
|
6
|
-
embedded_in :owner, polymorphic: true
|
6
|
+
embedded_in :owner, polymorphic: true
|
7
|
+
|
8
|
+
# Mongoid 7 does not support `touch: true` on polymorphic associations
|
9
|
+
after_save -> { owner.touch if owner? }
|
10
|
+
after_destroy -> { owner.touch if owner? }
|
11
|
+
after_touch -> { owner.touch if owner? }
|
7
12
|
end
|
8
13
|
|
9
14
|
class MyLock1 < MyLock
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cancancan
|
@@ -28,22 +28,22 @@ dependencies:
|
|
28
28
|
name: mongoid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
- - "
|
33
|
+
version: '7.0'
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 7.0.2
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - "
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
44
|
-
- - "
|
43
|
+
version: '7.0'
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 7.0.2
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|