permisi 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/generators/permisi/templates/initializer.rb +3 -0
- data/lib/permisi/backend/active_record/actor.rb +1 -1
- data/lib/permisi/config.rb +3 -2
- data/lib/permisi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20d261fa05615f1a2b28f377d652b0f74af4df86de9e7fbabd820259fcdb619f
|
4
|
+
data.tar.gz: e1b86647d121b1e8f975be3f29165bbc8527285a742edd7453d3e26aa3b476d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 202a1ce6aced43df306e00eb02ea82058b57b22459ffbe76749836bf37d2649417ccc1fcf5e868720638789a09c00a390e0968488e3d9003efb2432f3e298435
|
7
|
+
data.tar.gz: 5cf4ed22ff8b0531542d17e37e11bb0dd4d8ce9fc8f4cc744625fa815b77285065f952abcd53c1af8dcc81e0ba59410f163068e5a5e427dd06e26393d2a40862
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 0.1.5
|
4
|
+
|
5
|
+
[_View the docs._](https://github.com/ukazap/permisi/blob/v0.1.5/README.md)
|
6
|
+
|
7
|
+
- Remove `-> { distinct }` from actor-roles has_many association
|
8
|
+
- Add option to mute pre-0.1.4 ActiveRecord backend initialization warning:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
# config/initializers/permisi.rb
|
12
|
+
|
13
|
+
Permisi.init do |config|
|
14
|
+
# Mute pre-0.1.4 ActiveRecord backend initialization warning
|
15
|
+
config.mute_pre_0_1_4_warning = true
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
3
19
|
# 0.1.4
|
4
20
|
|
5
21
|
[_View the docs._](https://github.com/ukazap/permisi/blob/v0.1.4/README.md)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -169,7 +169,7 @@ end
|
|
169
169
|
You can then interact using `#permisi` method:
|
170
170
|
|
171
171
|
```ruby
|
172
|
-
user = User.find_by_email
|
172
|
+
user = User.find_by_email("esther@example.com")
|
173
173
|
user.permisi # => instance of Actor
|
174
174
|
|
175
175
|
admin_role = Permisi.roles.find_by_slug(:admin)
|
@@ -198,7 +198,7 @@ Permisi has several optimizations out of the box: actor roles eager loading, act
|
|
198
198
|
Although checking whether an actor has a role goes against a good RBAC practice, it is still possible on Permisi. Calling `role?` multiple times will only make one call to the database:
|
199
199
|
|
200
200
|
```ruby
|
201
|
-
user = User.find_by_email
|
201
|
+
user = User.find_by_email("esther@example.com")
|
202
202
|
user.permisi.role?(:admin) # eager loads roles
|
203
203
|
user.permisi.role?(:admin) # uses the eager-loaded roles
|
204
204
|
user.permisi.has_role?(:admin) # uses the eager-loaded roles
|
@@ -6,7 +6,7 @@ module Permisi
|
|
6
6
|
class Actor < ::ActiveRecord::Base
|
7
7
|
belongs_to :aka, polymorphic: true, touch: true
|
8
8
|
has_many :actor_roles, dependent: :destroy
|
9
|
-
has_many :roles,
|
9
|
+
has_many :roles, through: :actor_roles
|
10
10
|
|
11
11
|
after_commit :reset_permissions
|
12
12
|
|
data/lib/permisi/config.rb
CHANGED
@@ -7,6 +7,7 @@ module Permisi
|
|
7
7
|
NULL_CACHE_STORE = ActiveSupport::Cache::NullStore.new
|
8
8
|
|
9
9
|
attr_reader :permissions, :default_permissions
|
10
|
+
attr_accessor :mute_pre_0_1_4_warning
|
10
11
|
|
11
12
|
def initialize
|
12
13
|
@permissions = ::HashWithIndifferentAccess.new
|
@@ -16,10 +17,10 @@ module Permisi
|
|
16
17
|
def backend=(chosen_backend)
|
17
18
|
chosen_backend = "::Permisi::Backend::#{chosen_backend.to_s.classify}".constantize if chosen_backend.is_a? Symbol
|
18
19
|
|
19
|
-
if chosen_backend == Backend::ActiveRecord
|
20
|
+
if !mute_pre_0_1_4_warning && chosen_backend == Backend::ActiveRecord
|
20
21
|
warn <<~MESSAGE
|
21
22
|
|
22
|
-
WARNING: If you are upgrading from Permisi
|
23
|
+
WARNING: If you are upgrading from Permisi <v0.1.4, please create the following migration:
|
23
24
|
`add_index :permisi_actor_roles, [:actor_id, :role_id], unique: true`
|
24
25
|
|
25
26
|
MESSAGE
|
data/lib/permisi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: permisi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ukaza Perdana
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|