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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbab2a3e7461bdec8e23c4d9b1027cac1575efed88174a704c4178b1e666c442
4
- data.tar.gz: 03370daedb464860849fb9fab3144d6b718cad2a24044ea341deb7179d5879d5
3
+ metadata.gz: 9a0e978ec258c3a3b3e93fa34b6943c8af6b09666722b0ac2b61f196fa972394
4
+ data.tar.gz: 132f93b4885b86db918c22739859944b86d98e83a07fd7f90ac0e259b5d6e901
5
5
  SHA512:
6
- metadata.gz: 451a7e6d02d26419a0629584bf7a1627e2b58c8688db01f5b9bdfdeebec693b77d09ad1a46c5b40272fb31245e4e80476fb81b87606d40940a0b6d62aa0802b7
7
- data.tar.gz: '084a93016fbc7b4ec745502bbf98addb04754b7081738262e68682ac7ead9026b27c3b9439c81d86b895e3a1a9d603f58397ec5a61c6c23cdcb9240c890dab4e'
6
+ metadata.gz: 50b463ff75c3ecf23a1187b05fcba527c4b50bd47e3c4831d7aece79124b366194d28da44af3acb414f4d0a8de8c02799a24e321a138bab1046552463f7b8a4e
7
+ data.tar.gz: 06dee8bd65eacce1939aca16d3f6b001b7ed58e708f776903eeb3a2bd4873cf1a3d8d09e5a817590571113d29795b038ec979cacd6f243f43f18d07084d2efab
@@ -2,7 +2,7 @@ language: ruby
2
2
  script: 'bundle exec rake'
3
3
  sudo: false
4
4
  rvm:
5
- - 2.2.5
5
+ - 2.5.1
6
6
  services:
7
7
  - mongodb
8
8
 
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.0.0
4
+
5
+ * upgrade to Mongoid 7+
6
+
3
7
  ## 2.0.3
4
8
 
5
9
  * memoize `model_adapter` for better performance
@@ -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, touch: true, optional: 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
  delegate :can?, :cannot?,
7
9
  to: :ability
8
10
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MongoidAbility
2
- VERSION = '2.0.3'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
@@ -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', '>= 5', '< 7'
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.locks_relation.metadata[:name].must_equal :my_locks }
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, touch: 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: 2.0.3
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-08-16 00:00:00.000000000 Z
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: '5'
34
- - - "<"
33
+ version: '7.0'
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: '7'
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: '5'
44
- - - "<"
43
+ version: '7.0'
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '7'
46
+ version: 7.0.2
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement