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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b56c15224ab819fd173b51ce3cd341836a9edcbf6d2a0c0496813826c168f4c
4
- data.tar.gz: 1eb2ef335b4fa1a2790573ca118c9178cff6d96ef6d3334cc165650c216bbc97
3
+ metadata.gz: 20d261fa05615f1a2b28f377d652b0f74af4df86de9e7fbabd820259fcdb619f
4
+ data.tar.gz: e1b86647d121b1e8f975be3f29165bbc8527285a742edd7453d3e26aa3b476d5
5
5
  SHA512:
6
- metadata.gz: 9e099b2453555f7da80bfef2c4948a80523625271ba9666d2c053e455b0c42dc90d53f7f4a7233e1572696d58c7f1553dbdcaf38f9a4d6e351432a98de21d3ae
7
- data.tar.gz: ea49a2fa692188d5864da2322a37c01de5856fb3d5bb4529966328f45e2ccc0114119c07289fa12c68afffc7f9e2030db99a10815480f180f3ea17fccd082218
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- permisi (0.1.4)
4
+ permisi (0.1.5)
5
5
  activemodel (>= 3.2.0)
6
6
  activerecord (>= 3.2.0)
7
7
  activesupport (>= 3.2.0)
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 "esther@example.com"
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 "esther@example.com"
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
@@ -14,4 +14,7 @@ Permisi.init do |config|
14
14
  # Define cache store
15
15
  # See https://github.com/ukazap/permisi#caching
16
16
  config.cache_store = Rails.cache
17
+
18
+ # Mute pre-0.1.4 ActiveRecord backend initialization warning
19
+ config.mute_pre_0_1_4_warning = true
17
20
  end
@@ -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, -> { distinct }, through: :actor_roles
9
+ has_many :roles, through: :actor_roles
10
10
 
11
11
  after_commit :reset_permissions
12
12
 
@@ -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 && VERSION == "0.1.4"
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 >v0.1.4, please create the following migration:
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Permisi
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
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
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-23 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel