cancancan 2.3.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/cancancan.gemspec +6 -5
  3. data/init.rb +2 -0
  4. data/lib/cancan/ability/actions.rb +2 -0
  5. data/lib/cancan/ability/rules.rb +20 -9
  6. data/lib/cancan/ability/strong_parameter_support.rb +41 -0
  7. data/lib/cancan/ability.rb +54 -24
  8. data/lib/cancan/class_matcher.rb +30 -0
  9. data/lib/cancan/conditions_matcher.rb +72 -18
  10. data/lib/cancan/config.rb +101 -0
  11. data/lib/cancan/controller_additions.rb +5 -2
  12. data/lib/cancan/controller_resource.rb +7 -1
  13. data/lib/cancan/controller_resource_builder.rb +2 -0
  14. data/lib/cancan/controller_resource_finder.rb +2 -0
  15. data/lib/cancan/controller_resource_loader.rb +4 -0
  16. data/lib/cancan/controller_resource_name_finder.rb +2 -0
  17. data/lib/cancan/controller_resource_sanitizer.rb +2 -0
  18. data/lib/cancan/exceptions.rb +18 -2
  19. data/lib/cancan/matchers.rb +7 -2
  20. data/lib/cancan/model_adapters/abstract_adapter.rb +22 -1
  21. data/lib/cancan/model_adapters/active_record_4_adapter.rb +26 -25
  22. data/lib/cancan/model_adapters/active_record_5_adapter.rb +17 -26
  23. data/lib/cancan/model_adapters/active_record_adapter.rb +130 -15
  24. data/lib/cancan/model_adapters/conditions_extractor.rb +7 -7
  25. data/lib/cancan/model_adapters/conditions_normalizer.rb +49 -0
  26. data/lib/cancan/model_adapters/default_adapter.rb +2 -0
  27. data/lib/cancan/model_adapters/sti_normalizer.rb +47 -0
  28. data/lib/cancan/model_adapters/strategies/base.rb +40 -0
  29. data/lib/cancan/model_adapters/strategies/joined_alias_each_rule_as_exists_subquery.rb +93 -0
  30. data/lib/cancan/model_adapters/strategies/joined_alias_exists_subquery.rb +31 -0
  31. data/lib/cancan/model_adapters/strategies/left_join.rb +11 -0
  32. data/lib/cancan/model_adapters/strategies/subquery.rb +18 -0
  33. data/lib/cancan/model_additions.rb +6 -2
  34. data/lib/cancan/parameter_validators.rb +9 -0
  35. data/lib/cancan/relevant.rb +29 -0
  36. data/lib/cancan/rule.rb +67 -23
  37. data/lib/cancan/rules_compressor.rb +3 -0
  38. data/lib/cancan/sti_detector.rb +12 -0
  39. data/lib/cancan/unauthorized_message_resolver.rb +24 -0
  40. data/lib/cancan/version.rb +3 -1
  41. data/lib/cancan.rb +11 -0
  42. data/lib/cancancan.rb +2 -0
  43. data/lib/generators/cancan/ability/ability_generator.rb +3 -1
  44. data/lib/generators/cancan/ability/templates/ability.rb +9 -9
  45. metadata +37 -24
  46. data/lib/cancan/model_adapters/can_can/model_adapters/active_record_adapter/joins.rb +0 -39
metadata CHANGED
@@ -1,46 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancancan
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.5.0
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: 2018-09-16 00:00:00.000000000 Z
14
+ date: 2023-03-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: bundler
17
+ name: appraisal
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: '1.3'
22
+ version: '2.0'
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 2.0.0
23
26
  type: :development
24
27
  prerelease: false
25
28
  version_requirements: !ruby/object:Gem::Requirement
26
29
  requirements:
27
30
  - - "~>"
28
31
  - !ruby/object:Gem::Version
29
- version: '1.3'
32
+ version: '2.0'
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.0.0
30
36
  - !ruby/object:Gem::Dependency
31
- name: rubocop
37
+ name: bundler
32
38
  requirement: !ruby/object:Gem::Requirement
33
39
  requirements:
34
40
  - - "~>"
35
41
  - !ruby/object:Gem::Version
36
- version: 0.48.1
42
+ version: '2.0'
37
43
  type: :development
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
40
46
  requirements:
41
47
  - - "~>"
42
48
  - !ruby/object:Gem::Version
43
- version: 0.48.1
49
+ version: '2.0'
44
50
  - !ruby/object:Gem::Dependency
45
51
  name: rake
46
52
  requirement: !ruby/object:Gem::Requirement
@@ -82,25 +88,19 @@ dependencies:
82
88
  - !ruby/object:Gem::Version
83
89
  version: 3.2.0
84
90
  - !ruby/object:Gem::Dependency
85
- name: appraisal
91
+ name: rubocop
86
92
  requirement: !ruby/object:Gem::Requirement
87
93
  requirements:
88
94
  - - "~>"
89
95
  - !ruby/object:Gem::Version
90
- version: '2.0'
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: 2.0.0
96
+ version: 1.31.1
94
97
  type: :development
95
98
  prerelease: false
96
99
  version_requirements: !ruby/object:Gem::Requirement
97
100
  requirements:
98
101
  - - "~>"
99
102
  - !ruby/object:Gem::Version
100
- version: '2.0'
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: 2.0.0
103
+ version: 1.31.1
104
104
  description: Simple authorization solution for Rails. All permissions are stored in
105
105
  a single location.
106
106
  email: alessandro.rodi@renuo.ch
@@ -114,7 +114,10 @@ files:
114
114
  - lib/cancan/ability.rb
115
115
  - lib/cancan/ability/actions.rb
116
116
  - lib/cancan/ability/rules.rb
117
+ - lib/cancan/ability/strong_parameter_support.rb
118
+ - lib/cancan/class_matcher.rb
117
119
  - lib/cancan/conditions_matcher.rb
120
+ - lib/cancan/config.rb
118
121
  - lib/cancan/controller_additions.rb
119
122
  - lib/cancan/controller_resource.rb
120
123
  - lib/cancan/controller_resource_builder.rb
@@ -128,12 +131,22 @@ files:
128
131
  - lib/cancan/model_adapters/active_record_4_adapter.rb
129
132
  - lib/cancan/model_adapters/active_record_5_adapter.rb
130
133
  - lib/cancan/model_adapters/active_record_adapter.rb
131
- - lib/cancan/model_adapters/can_can/model_adapters/active_record_adapter/joins.rb
132
134
  - lib/cancan/model_adapters/conditions_extractor.rb
135
+ - lib/cancan/model_adapters/conditions_normalizer.rb
133
136
  - lib/cancan/model_adapters/default_adapter.rb
137
+ - lib/cancan/model_adapters/sti_normalizer.rb
138
+ - lib/cancan/model_adapters/strategies/base.rb
139
+ - lib/cancan/model_adapters/strategies/joined_alias_each_rule_as_exists_subquery.rb
140
+ - lib/cancan/model_adapters/strategies/joined_alias_exists_subquery.rb
141
+ - lib/cancan/model_adapters/strategies/left_join.rb
142
+ - lib/cancan/model_adapters/strategies/subquery.rb
134
143
  - lib/cancan/model_additions.rb
144
+ - lib/cancan/parameter_validators.rb
145
+ - lib/cancan/relevant.rb
135
146
  - lib/cancan/rule.rb
136
147
  - lib/cancan/rules_compressor.rb
148
+ - lib/cancan/sti_detector.rb
149
+ - lib/cancan/unauthorized_message_resolver.rb
137
150
  - lib/cancan/version.rb
138
151
  - lib/cancancan.rb
139
152
  - lib/generators/cancan/ability/USAGE
@@ -142,8 +155,9 @@ files:
142
155
  homepage: https://github.com/CanCanCommunity/cancancan
143
156
  licenses:
144
157
  - MIT
145
- metadata: {}
146
- post_install_message:
158
+ metadata:
159
+ funding_uri: https://github.com/sponsors/coorasse
160
+ post_install_message:
147
161
  rdoc_options: []
148
162
  require_paths:
149
163
  - lib
@@ -158,9 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
172
  - !ruby/object:Gem::Version
159
173
  version: '0'
160
174
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.7.4
163
- signing_key:
175
+ rubygems_version: 3.3.7
176
+ signing_key:
164
177
  specification_version: 4
165
178
  summary: Simple authorization solution for Rails.
166
179
  test_files: []
@@ -1,39 +0,0 @@
1
- module CanCan
2
- module ModelAdapters
3
- module ActiveRecordAdapter
4
- module Joins
5
- # Returns the associations used in conditions for the :joins option of a search.
6
- # See ModelAdditions#accessible_by
7
- def joins
8
- joins_hash = {}
9
- @rules.reverse.each do |rule|
10
- merge_joins(joins_hash, rule.associations_hash)
11
- end
12
- clean_joins(joins_hash) unless joins_hash.empty?
13
- end
14
-
15
- private
16
-
17
- # Removes empty hashes and moves everything into arrays.
18
- def clean_joins(joins_hash)
19
- joins = []
20
- joins_hash.each do |name, nested|
21
- joins << (nested.empty? ? name : { name => clean_joins(nested) })
22
- end
23
- joins
24
- end
25
-
26
- # Takes two hashes and does a deep merge.
27
- def merge_joins(base, add)
28
- add.each do |name, nested|
29
- if base[name].is_a?(Hash)
30
- merge_joins(base[name], nested) unless nested.empty?
31
- else
32
- base[name] = nested
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end