consent 1.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +13 -6
  3. data/.rubocop.yml +17 -0
  4. data/.rubocop_todo.yml +9 -11
  5. data/Appraisals +13 -0
  6. data/Gemfile +10 -1
  7. data/Gemfile.lock +259 -0
  8. data/Rakefile +9 -3
  9. data/app/models/concerns/consent/authorizable.rb +94 -0
  10. data/app/models/consent/application_record.rb +7 -0
  11. data/app/models/consent/history.rb +21 -0
  12. data/app/models/consent/permission.rb +71 -0
  13. data/bin/console +3 -3
  14. data/config.ru +9 -0
  15. data/consent.gemspec +25 -21
  16. data/db/migrate/20211104225614_create_nitro_auth_authorization_permissions.rb +19 -0
  17. data/db/migrate/20220420135558_create_nitro_auth_authorization_histories.rb +15 -0
  18. data/doc/dependency_decisions.yml +3 -0
  19. data/docs/CHANGELOG.md +32 -0
  20. data/docs/README.md +355 -0
  21. data/gemfiles/.bundle/config +2 -0
  22. data/gemfiles/rails_6_1.gemfile +15 -0
  23. data/gemfiles/rails_6_1.gemfile.lock +287 -0
  24. data/gemfiles/rails_7_0.gemfile +15 -0
  25. data/gemfiles/rails_7_0.gemfile.lock +286 -0
  26. data/gemfiles/rails_7_1.gemfile +15 -0
  27. data/gemfiles/rails_7_1.gemfile.lock +337 -0
  28. data/lib/consent/ability.rb +113 -4
  29. data/lib/consent/dsl.rb +1 -8
  30. data/lib/consent/{railtie.rb → engine.rb} +11 -8
  31. data/lib/consent/model_additions.rb +64 -0
  32. data/lib/consent/permission_migration.rb +139 -0
  33. data/lib/consent/reloader.rb +6 -5
  34. data/lib/consent/rspec/consent_action.rb +7 -7
  35. data/lib/consent/rspec/consent_view.rb +10 -14
  36. data/lib/consent/rspec.rb +3 -3
  37. data/lib/consent/subject_coder.rb +39 -0
  38. data/lib/consent/symbol_adapter.rb +18 -0
  39. data/lib/consent/version.rb +1 -1
  40. data/lib/consent.rb +25 -13
  41. data/lib/generators/consent/permissions_generator.rb +5 -5
  42. data/mkdocs.yml +6 -0
  43. data/renovate.json +15 -2
  44. metadata +126 -37
  45. data/.rspec +0 -2
  46. data/.ruby-version +0 -1
  47. data/.travis.yml +0 -20
  48. data/LICENSE +0 -21
  49. data/README.md +0 -252
  50. data/TODO.md +0 -1
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2025-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cancancan
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activerecord
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,61 +39,103 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '5'
27
41
  - !ruby/object:Gem::Dependency
28
- name: bundler
42
+ name: appraisal
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ">="
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 1.17.3
47
+ version: 2.5.0
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 1.17.3
54
+ version: 2.5.0
41
55
  - !ruby/object:Gem::Dependency
42
- name: cancancan
56
+ name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 1.15.0
61
+ version: '2.1'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 1.15.0
68
+ version: '2.1'
55
69
  - !ruby/object:Gem::Dependency
56
- name: pry
70
+ name: combustion
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 0.14.1
75
+ version: '1.3'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 0.14.1
82
+ version: '1.3'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: license_finder
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: 12.3.3
89
+ version: '7.0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: 12.3.3
96
+ version: '7.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.14.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.14.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.10.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 3.10.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '13'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '13'
83
139
  - !ruby/object:Gem::Dependency
84
140
  name: rspec
85
141
  requirement: !ruby/object:Gem::Requirement
@@ -95,34 +151,48 @@ dependencies:
95
151
  - !ruby/object:Gem::Version
96
152
  version: '3.0'
97
153
  - !ruby/object:Gem::Dependency
98
- name: rubocop
154
+ name: rspec-rails
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
157
  - - "~>"
102
158
  - !ruby/object:Gem::Version
103
- version: 0.65.0
159
+ version: 6.1.5
104
160
  type: :development
105
161
  prerelease: false
106
162
  version_requirements: !ruby/object:Gem::Requirement
107
163
  requirements:
108
164
  - - "~>"
109
165
  - !ruby/object:Gem::Version
110
- version: 0.65.0
166
+ version: 6.1.5
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-powerhome
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 0.5.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 0.5.0
111
181
  - !ruby/object:Gem::Dependency
112
182
  name: sqlite3
113
183
  requirement: !ruby/object:Gem::Requirement
114
184
  requirements:
115
185
  - - "~>"
116
186
  - !ruby/object:Gem::Version
117
- version: 1.4.2
187
+ version: 1.7.3
118
188
  type: :development
119
189
  prerelease: false
120
190
  version_requirements: !ruby/object:Gem::Requirement
121
191
  requirements:
122
192
  - - "~>"
123
193
  - !ruby/object:Gem::Version
124
- version: 1.4.2
125
- description: Consent
194
+ version: 1.7.3
195
+ description: Consent permission based authorization
126
196
  email:
127
197
  - chjunior@gmail.com
128
198
  executables: []
@@ -130,40 +200,59 @@ extensions: []
130
200
  extra_rdoc_files: []
131
201
  files:
132
202
  - ".gitignore"
133
- - ".rspec"
134
203
  - ".rubocop.yml"
135
204
  - ".rubocop_todo.yml"
136
- - ".ruby-version"
137
- - ".travis.yml"
205
+ - Appraisals
138
206
  - Gemfile
139
- - LICENSE
140
- - README.md
207
+ - Gemfile.lock
141
208
  - Rakefile
142
- - TODO.md
209
+ - app/models/concerns/consent/authorizable.rb
210
+ - app/models/consent/application_record.rb
211
+ - app/models/consent/history.rb
212
+ - app/models/consent/permission.rb
143
213
  - bin/console
144
214
  - bin/setup
215
+ - config.ru
145
216
  - consent.gemspec
217
+ - db/migrate/20211104225614_create_nitro_auth_authorization_permissions.rb
218
+ - db/migrate/20220420135558_create_nitro_auth_authorization_histories.rb
219
+ - doc/dependency_decisions.yml
220
+ - docs/CHANGELOG.md
221
+ - docs/README.md
222
+ - gemfiles/.bundle/config
223
+ - gemfiles/rails_6_1.gemfile
224
+ - gemfiles/rails_6_1.gemfile.lock
225
+ - gemfiles/rails_7_0.gemfile
226
+ - gemfiles/rails_7_0.gemfile.lock
227
+ - gemfiles/rails_7_1.gemfile
228
+ - gemfiles/rails_7_1.gemfile.lock
146
229
  - lib/consent.rb
147
230
  - lib/consent/ability.rb
148
231
  - lib/consent/action.rb
149
232
  - lib/consent/dsl.rb
150
- - lib/consent/railtie.rb
233
+ - lib/consent/engine.rb
234
+ - lib/consent/model_additions.rb
235
+ - lib/consent/permission_migration.rb
151
236
  - lib/consent/reloader.rb
152
237
  - lib/consent/rspec.rb
153
238
  - lib/consent/rspec/consent_action.rb
154
239
  - lib/consent/rspec/consent_view.rb
155
240
  - lib/consent/subject.rb
241
+ - lib/consent/subject_coder.rb
242
+ - lib/consent/symbol_adapter.rb
156
243
  - lib/consent/version.rb
157
244
  - lib/consent/view.rb
158
245
  - lib/generators/consent/permissions_generator.rb
159
246
  - lib/generators/consent/templates/permissions.rb.erb
160
247
  - lib/generators/consent/templates/permissions_spec.rb.erb
248
+ - mkdocs.yml
161
249
  - renovate.json
162
- homepage:
250
+ homepage: https://github.com/powerhome/power-tools
163
251
  licenses:
164
252
  - MIT
165
- metadata: {}
166
- post_install_message:
253
+ metadata:
254
+ rubygems_mfa_required: 'true'
255
+ post_install_message:
167
256
  rdoc_options: []
168
257
  require_paths:
169
258
  - lib
@@ -171,15 +260,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
260
  requirements:
172
261
  - - ">="
173
262
  - !ruby/object:Gem::Version
174
- version: '0'
263
+ version: '3.0'
175
264
  required_rubygems_version: !ruby/object:Gem::Requirement
176
265
  requirements:
177
266
  - - ">="
178
267
  - !ruby/object:Gem::Version
179
268
  version: '0'
180
269
  requirements: []
181
- rubygems_version: 3.0.8
182
- signing_key:
270
+ rubygems_version: 3.5.23
271
+ signing_key:
183
272
  specification_version: 4
184
- summary: Consent
273
+ summary: Consent permission based authorization
185
274
  test_files: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.5.0
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.8
5
- - 2.6.6
6
- - 2.7.2
7
- - 3.0.0
8
- before_install: gem install bundler -v 1.17.3
9
- script:
10
- - bundle exec rubocop
11
- - bundle exec rspec
12
- deploy:
13
- provider: rubygems
14
- api_key:
15
- secure: aCipdg6IqKaxQmWQXFlqI2JqGOrCAxzYlutOn6nCSk9VCzmlRjDoEp1M99ASvmF5CP3KQgfRq8bxfLql8jss8tymK0u2ExvKaUglK0zb2KoLQDGDGuHw3RxCTnaxPBuO4/2PuS+nso6IcdqUaGOzh8FA7ePKPBmxl3kyNtArEDV88Eyx6tQYs1/1w153bAeBk57nTiu8CPS+dIWg+guQADTLPZ61fH4xKjPWXnr65pFF7YtU5YdPBHFkqL60X384OZj1c7ZTGvFj70+36oo617HigSg8HCE+E0R1N4JQ8/5xo2yHBdrtgsAqYyYWRgm1C6qu+T6yKMuokdoSd0Ji3Rigz6VRrOJfjmQQkwMnno9fCY3vND62zOb9Ow+MCNuQYSgNHc+YPURKmT05wadG0FpZdmo6hstPusleuG89NxnB/s2YjR0QWQK05MW1uhFdru1S2gBd1fMH1GLoThhdfGG1UJSkKOipUJyRupFaB9zimJO3HwaTP0Q+wP8MGZDAqbyzQ3bJSZaQmJC6loC2EtxxnOQxUIxaySLtNEU2LOr9IijExj1ldXkz8X1fIWwRr6BPnIeChFnuST+L9UDYtqk1WgQTUs+tOAxUjepAWhtIUL5h3Jg2NZd9RxPXq8IngDWZJwT8yA3E9wloQx5JzTIMas5wHwCQJuwjjk5ibss=
16
- gem: consent
17
- on:
18
- tags: true
19
- repo: powerhome/consent
20
- ruby: 2.6.6
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright Power Home Remodeling Group, LLC
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/README.md DELETED
@@ -1,252 +0,0 @@
1
- # Consent [![Build Status](https://travis-ci.org/powerhome/consent.svg?branch=master)](https://travis-ci.org/powerhome/consent)
2
-
3
- ## Installation
4
-
5
- Add this line to your application's Gemfile:
6
-
7
- ```ruby
8
- gem 'consent'
9
- ```
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install consent
18
-
19
- ## What is Consent
20
-
21
- Consent makes defining permissions easier by providing a clean, concise DSL for authorization
22
- so that all abilities do not have to be in your `Ability`
23
- class.
24
-
25
- Consent takes application permissions and models them so that permissions are organized and can
26
- be defined granularly. It does so using the following models:
27
-
28
- * View: A collection of objects limited by a given condition.
29
- * Action: An action performed on top of the objects limited by the view. For example, one user could only `:view` something, while another could `:manage` it.
30
- * Subject: Holds the scope of the actions.
31
- * Permission: The combination of a subject, an action, and a view (or full-access).
32
-
33
- ## What Consent Is Not
34
-
35
- Consent isn't a tool to enforce permissions -- it supports CanCan(Can) for that goal.
36
-
37
- ## Subject
38
-
39
- The subject is the central point of a group of actions and views. It will typically
40
- be an `ActiveRecord` class, a `:symbol`, or any Plain Old Ruby Object.
41
-
42
- You define a subject with the following DSL:
43
-
44
- ```ruby
45
- Consent.define Project, 'Our Projects' do
46
- #in this case, Project is the subject
47
- # and `Our Projects` is the description that makes it clear to users
48
- # what the subject is acting upon.
49
-
50
- end
51
- ```
52
-
53
- The scope is the action that's being performed on the subject. It can be anything, but will
54
- typically be an ActiveRecord class, a `:symbol`, or a PORO.
55
-
56
- For instance:
57
-
58
- ```ruby
59
- Consent.define :features, 'Beta Features' do
60
- # whatever you put inside this method defines the scope
61
- end
62
- ```
63
-
64
- ## Views
65
-
66
- Views are the rules that limit access to actions. For instance, a user may see a `Project`
67
- from his department, but not from others. You can enforce it with a `:department` view,
68
- as in the examples below:
69
-
70
- ### Hash Conditions
71
-
72
- Probably the most commonly used. When the view can be defined using a `where` scope in
73
- an ActiveRecord context. It follows a match condition and will return all objects that meet
74
- the criteria:
75
-
76
- ```ruby
77
- Consent.define Project, 'Projects' do
78
- view :department, "User's department only" do |user|
79
- { department_id: user.id }
80
- end
81
- end
82
- ```
83
-
84
- Although hash conditions (matching object's attributes) are recommended, the constraints can
85
- be anything you want. Since Consent does not enforce the rules, those rules are directly given
86
- to CanCan. Following [CanCan rules](https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities%3A-Best-Practice)
87
- for defining abilities is recommended.
88
-
89
- ### Object Conditions
90
-
91
- If you're not matching for equal values, then you would need to use an object condition.
92
-
93
- If you already have an object and want to check to see whether the user has permission to view
94
- that specific object, you would use object conditions.
95
-
96
- If your needs can't be satisfied by hash conditions, it is recommended that a second condition
97
- is given for constraining object instances. For example, if you want to restrict a view for smaller
98
- volume projects:
99
-
100
- ```ruby
101
- Consent.define Project, 'Projects' do
102
- view :small_volumes, "User's department only",
103
- -> (user) {
104
- ['amount < ?', user.volume_limit]
105
- end,
106
- -> (user, project) {
107
- project.amount < user.volume_limit
108
- }
109
- end
110
- ```
111
-
112
- For object conditions, the latter argument will be the referred object, while the
113
- first will be the context given to the [Permission](#permission) (also check
114
- [CanCan integration](#cancan-integration)).
115
-
116
- ## Action
117
-
118
- An action is anything you can perform on a given subject. In the example of
119
- Features this would look like the following using Consent's DSL:
120
-
121
- ```ruby
122
- Consent.define :features, 'Beta Features' do
123
- action :beta_chat, 'Beta Chat App'
124
- end
125
- ```
126
-
127
- To associate different views to the same action:
128
-
129
- ```ruby
130
- Consent.define Project, 'Projects' do
131
- # returns conditions that can be used as a matcher for objects so the matcher
132
- # can return true or false (hash version)
133
- view :department, "User's department only" do |user|
134
- { department_id: user.id }
135
- end
136
- view :future_projects, "User's department only",
137
- # returns a condition to be applied to a collection of objects
138
- -> (_) {
139
- ['starts_at > ?', Date.today]
140
- end,
141
- # returns true/false based on a condition -- to use this, you must pass in
142
- # an instance of an object in order to check the permission
143
- -> (user, project) {
144
- project.starts_at > Date.today
145
- }
146
-
147
- action :read, 'Read projects', views: [:department, :future_projects]
148
- end
149
- ```
150
-
151
- If you have a set of actions with the same set of views, you can use a
152
- `with_defaults` block to simplify the writing:
153
-
154
- ```ruby
155
- with_defaults views: [:department, :small_volumes] do
156
- action :read, 'Read projects'
157
- action :approve, 'Approve projects'
158
- end
159
- ```
160
-
161
- ## Permission
162
-
163
- A permission is what is consented to the user. It consentment to perform
164
- an *action* on a limited *view* of the *subject*. It marries the three concepts
165
- to consent an access to the user.
166
-
167
- ## CanCan Integration
168
-
169
- Consent provides a CanCan ability (Consent::Ability) to integrate your
170
- permissions with frameworks like Rails. To use it with Rails check out the
171
- example at [Ability for Other Users](https://github.com/CanCanCommunity/cancancan/wiki/Ability-for-Other-Users)
172
- on CanCanCan's wiki.
173
-
174
- In the ability you define the scope of the permissions. This is typically a
175
- user:
176
-
177
- ```ruby
178
- Consent::Ability.new(user)
179
- ```
180
-
181
- You'd more commonly define a subclass of `Consent::Ability`, and consent access
182
- to the user by calling `consent`:
183
-
184
- ```ruby
185
- class MyAbility < Consent::Ability
186
- def initialize(user)
187
- super user
188
-
189
- consent :read, Project, :department
190
- end
191
- end
192
- ```
193
-
194
- You can also consent full access by not specifying the view:
195
-
196
- ```ruby
197
- consent :read, Project
198
- ```
199
-
200
- If you have a somehow manageable permission, you can consent them in batch in your ability:
201
-
202
- ```ruby
203
- class MyAbility < Consent::Ability
204
- def initialize(user)
205
- super user
206
-
207
- user.permissions.each do |permission|
208
- consent permission.action, permission.subject, permission.view
209
- end
210
- end
211
- end
212
- ```
213
-
214
- Consenting the same permission multiple times is handled as a Union by CanCanCan:
215
-
216
- ```ruby
217
- class MyAbility < Consent::Ability
218
- def initialize(user)
219
- super user
220
-
221
- consent :read, Project, :department
222
- consent :read, Project, :future_projects
223
- end
224
- end
225
-
226
- user = User.new(department_id: 13)
227
- ability = MyAbility.new(user)
228
-
229
- Project.accessible_by(ability, :read).to_sql
230
- => SELECT * FROM projects WHERE ((department_id = 13) OR (starts_at > '2021-04-06'))
231
- ```
232
-
233
- ## Rails Integration
234
-
235
- Consent is integrated into Rails with `Consent::Railtie`. To define where
236
- your permission files will be, use `config.consent.path`. This defaults to
237
- `#{Rails.root}/app/permissions/` to conform to Rails' standards.
238
-
239
- ## Development
240
-
241
- After checking out the repo, run `bin/setup` to install dependencies. Then, run
242
- `rake spec` to run the tests. You can also run `bin/console` for an interactive
243
- prompt that will allow you to experiment.
244
-
245
- To install this gem onto your local machine, run `bundle exec rake install`. To
246
- release a new version, update the version number in `version.rb`, and then run
247
- `bundle exec rake release`, which will create a git tag for the version, push
248
- git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
249
-
250
- ## Contributing
251
-
252
- Bug reports and pull requests are welcome on GitHub at https://github.com/powerhome/consent.
data/TODO.md DELETED
@@ -1 +0,0 @@
1
- * DSL validate Consent state