cancancan 2.1.1 → 2.1.2

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: a754d91858c1b6c433c9b7c12d6b4e99440c0cc0
4
- data.tar.gz: 31d2172742361e8a5ee8e7d74d2d5ca3a8e0e681
3
+ metadata.gz: a0cac57012f776fb962fcfa0fd97d92c11b47628
4
+ data.tar.gz: c0c7f568a6307585076c3ffb622dd2f5d1f464e3
5
5
  SHA512:
6
- metadata.gz: 6a15feefdba0ac03be2609772608006b2a4546d8ce5bcfd1e1a656a136ad87c837a2b3506bc57c8ae57747b47c6464d4e5912c5252c41b5acc4f625a3aaa01bc
7
- data.tar.gz: 6492f1fd59db034738c473a7c25677037d7ab37aabb644b4cffb057ed97e53519e25c9aa90d7048f2485088859094824af9dad7926d0ec27d3e2ff20b331ba33
6
+ metadata.gz: c5198aeba210ef606f29cb1c743edafa78c0022ad25ffa0c20363050e9fca225133f97ee1482fe50857182e90d0c70346bcb9880c02dedbe741270ecb10aad10
7
+ data.tar.gz: 32ffcf4998583cce920d79d4f1401f5dcbfe6df0a15b6199591079cbd586cb57defc4f892d01f083b16471c700dd2ba377eb0a63ab6b995a3db4c27d8df55d4d
@@ -202,6 +202,28 @@ module CanCan
202
202
  relevant_rules(action, subject).any?(&:only_raw_sql?)
203
203
  end
204
204
 
205
+ # Copies all rules of the given +CanCan::Ability+ and adds them to +self+.
206
+ # class ReadAbility
207
+ # include CanCan::Ability
208
+ #
209
+ # def initialize
210
+ # can :read, User
211
+ # end
212
+ # end
213
+ #
214
+ # class WritingAbility
215
+ # include CanCan::Ability
216
+ #
217
+ # def initialize
218
+ # can :edit, User
219
+ # end
220
+ # end
221
+ #
222
+ # read_ability = ReadAbility.new
223
+ # read_ability.can? :edit, User.new #=> false
224
+ # read_ability.merge(WritingAbility.new)
225
+ # read_ability.can? :edit, User.new #=> true
226
+ #
205
227
  def merge(ability)
206
228
  ability.rules.each do |rule|
207
229
  add_rule(rule.dup)
@@ -13,11 +13,16 @@ module CanCan
13
13
  end
14
14
 
15
15
  def find_resource_using_find_by
16
- if resource_base.respond_to? 'find_by'
17
- resource_base.send('find_by', @options[:find_by].to_sym => id_param)
18
- else
19
- resource_base.send(@options[:find_by], id_param)
20
- end
16
+ find_by_dynamic_finder || find_by_find_by_finder || resource_base.send(@options[:find_by], id_param)
17
+ end
18
+
19
+ def find_by_dynamic_finder
20
+ method_name = "find_by_#{@options[:find_by]}!"
21
+ resource_base.send(method_name, id_param) if resource_base.respond_to? method_name
22
+ end
23
+
24
+ def find_by_find_by_finder
25
+ resource_base.find_by(@options[:find_by].to_sym => id_param) if resource_base.respond_to? :find_by
21
26
  end
22
27
 
23
28
  def id_param
@@ -1,3 +1,3 @@
1
1
  module CanCan
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,48 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancancan
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi (Renuo AG)
8
8
  - Bryan Rite
9
9
  - Ryan Bates
10
10
  - Richard Wilson
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-11-13 00:00:00.000000000 Z
14
+ date: 2017-11-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: bundler
18
17
  requirement: !ruby/object:Gem::Requirement
19
18
  requirements:
20
19
  - - "~>"
21
20
  - !ruby/object:Gem::Version
22
21
  version: '1.3'
23
- type: :development
22
+ name: bundler
24
23
  prerelease: false
24
+ type: :development
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.3'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rubocop
32
31
  requirement: !ruby/object:Gem::Requirement
33
32
  requirements:
34
33
  - - "~>"
35
34
  - !ruby/object:Gem::Version
36
35
  version: 0.48.1
37
- type: :development
36
+ name: rubocop
38
37
  prerelease: false
38
+ type: :development
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.48.1
44
44
  - !ruby/object:Gem::Dependency
45
- name: rake
46
45
  requirement: !ruby/object:Gem::Requirement
47
46
  requirements:
48
47
  - - "~>"
@@ -51,8 +50,9 @@ dependencies:
51
50
  - - ">="
52
51
  - !ruby/object:Gem::Version
53
52
  version: 10.1.1
54
- type: :development
53
+ name: rake
55
54
  prerelease: false
55
+ type: :development
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
@@ -62,7 +62,6 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: 10.1.1
64
64
  - !ruby/object:Gem::Dependency
65
- name: rspec
66
65
  requirement: !ruby/object:Gem::Requirement
67
66
  requirements:
68
67
  - - "~>"
@@ -71,8 +70,9 @@ dependencies:
71
70
  - - ">="
72
71
  - !ruby/object:Gem::Version
73
72
  version: 3.2.0
74
- type: :development
73
+ name: rspec
75
74
  prerelease: false
75
+ type: :development
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
@@ -82,7 +82,6 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: 3.2.0
84
84
  - !ruby/object:Gem::Dependency
85
- name: appraisal
86
85
  requirement: !ruby/object:Gem::Requirement
87
86
  requirements:
88
87
  - - "~>"
@@ -91,8 +90,9 @@ dependencies:
91
90
  - - ">="
92
91
  - !ruby/object:Gem::Version
93
92
  version: 2.0.0
94
- type: :development
93
+ name: appraisal
95
94
  prerelease: false
95
+ type: :development
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
98
  - - "~>"
@@ -101,8 +101,7 @@ dependencies:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.0.0
104
- description: Simple authorization solution for Rails. All permissions are stored in
105
- a single location.
104
+ description: Simple authorization solution for Rails. All permissions are stored in a single location.
106
105
  email: alessandro.rodi@renuo.ch
107
106
  executables: []
108
107
  extensions: []
@@ -140,7 +139,7 @@ homepage: https://github.com/CanCanCommunity/cancancan
140
139
  licenses:
141
140
  - MIT
142
141
  metadata: {}
143
- post_install_message:
142
+ post_install_message:
144
143
  rdoc_options: []
145
144
  require_paths:
146
145
  - lib
@@ -155,9 +154,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
154
  - !ruby/object:Gem::Version
156
155
  version: '0'
157
156
  requirements: []
158
- rubyforge_project:
159
- rubygems_version: 2.6.13
160
- signing_key:
157
+ rubyforge_project:
158
+ rubygems_version: 2.4.8
159
+ signing_key:
161
160
  specification_version: 4
162
161
  summary: Simple authorization solution for Rails.
163
162
  test_files: []