ez-permissions 0.4.2 → 0.4.3

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
  SHA256:
3
- metadata.gz: 145430f6d759fbe5bbba86465d89d3bb184777997ce7d731a46f86118e62c5ca
4
- data.tar.gz: 9845fee84a035d8210793505514de5de55b9a1a22445ea6fe08c0fc990933be0
3
+ metadata.gz: f220c1b6b47d2c4ec04c717591243c0256a5870f5802005a38a4c451104ea574
4
+ data.tar.gz: 68dba463fa3ece4365ee47c3443ea859aac01b010b001c67a6419e61e910efdc
5
5
  SHA512:
6
- metadata.gz: 2b1088848755c808ed70bbdc57a14089b5aa86a7bbaf5e065cde35e9f58b89afcdb835d542addcfd8c1b2be273f8ac34c592699722292ca314946dae0a799805
7
- data.tar.gz: 376a1aa4d0e4742dd2fc47462f839650c5bc8507cf14fd883ef50cb9b0f73b1f0971df905881875f51fd37f623f447671a220caf88663c49229e65b0baa52c5c
6
+ metadata.gz: 23f50653976ef276868f2c4bb0bcce1fd71582b424da461345138cb04bcc25c8cd75cdda2b5b66a2474536f3474535f5fa7780f5ae3618d4407b3e020f3dc14a
7
+ data.tar.gz: ba64376d6c05184036cdb550ed39229485105af12f95f78132756893131bbf4a9fa7eeb2c67d865659c2ea10ad1fee53be01397652ddf0f237cd7ab51a689c82
data/README.md CHANGED
@@ -72,8 +72,8 @@ Ez::Permissions::DSL.define do |setup|
72
72
  setup.add :permissions, actions: %i[crud my_custom_action]
73
73
 
74
74
  # Actions option are not required. In such case you add all crud actions by default
75
- setup.add :users
76
- setup.add :projects
75
+ setup.add :users, group: :accounts # You can group resources
76
+ setup.add :projects # Resource without a group will get "others" group
77
77
  end
78
78
  ```
79
79
 
@@ -7,16 +7,16 @@ module Ez
7
7
  def self.included(base)
8
8
  base.has_many :assigned_roles,
9
9
  class_name: 'Ez::Permissions::ModelRole',
10
- as: :model
10
+ as: :model
11
11
 
12
12
  base.has_many :roles,
13
13
  -> { distinct },
14
- through: :assigned_roles,
14
+ through: :assigned_roles,
15
15
  class_name: 'Ez::Permissions::Role'
16
16
 
17
17
  base.has_many :permissions,
18
18
  -> { distinct },
19
- through: :roles,
19
+ through: :roles,
20
20
  class_name: 'Ez::Permissions::Permission'
21
21
  end
22
22
  # rubocop:enable Metrics/MethodLength
@@ -53,9 +53,9 @@ module Ez
53
53
  permission_ids = Ez::Permissions::PermissionRole.where(role_id: role_ids).pluck(:permission_id)
54
54
 
55
55
  Ez::Permissions::Permission.where(
56
- id: permission_ids,
56
+ id: permission_ids,
57
57
  resource: resource,
58
- action: actions.map(&:to_s)
58
+ action: actions.map(&:to_s)
59
59
  )
60
60
  end
61
61
 
@@ -8,8 +8,8 @@ module Ez
8
8
  role = Ez::Permissions::API.get_role!(role_name)
9
9
 
10
10
  Ez::Permissions::ModelRole.find_or_create_by!(
11
- role: role,
12
- model: model,
11
+ role: role,
12
+ model: model,
13
13
  scoped: scoped
14
14
  )
15
15
  end
@@ -30,8 +30,8 @@ module Ez
30
30
 
31
31
  def model_role(role, model, scoped)
32
32
  Ez::Permissions::ModelRole.find_by(
33
- role: role,
34
- model: model,
33
+ role: role,
34
+ model: model,
35
35
  scoped: scoped
36
36
  )
37
37
  end
@@ -28,7 +28,7 @@ module Ez
28
28
  permission = get_permission!(action, resource)
29
29
 
30
30
  Ez::Permissions::PermissionRole.find_by(
31
- role: role,
31
+ role: role,
32
32
  permission: permission
33
33
  )&.delete
34
34
  end
@@ -37,7 +37,7 @@ module Ez
37
37
 
38
38
  def grant_single_permission(role, permission)
39
39
  Ez::Permissions::PermissionRole.find_or_create_by!(
40
- role: role,
40
+ role: role,
41
41
  permission: permission
42
42
  )
43
43
  end
@@ -62,7 +62,7 @@ module Ez
62
62
  resource.actions.each do |action|
63
63
  Ez::Permissions::Permission.where(
64
64
  resource: resource.name,
65
- action: action
65
+ action: action
66
66
  ).first_or_create!
67
67
  end
68
68
  end
@@ -11,7 +11,7 @@ module Ez
11
11
  @name = name
12
12
  @model = options.fetch(:model, nil)
13
13
  @actions = process_actions(options.fetch(:actions, []))
14
- @group = options.fetch(:group, nil)
14
+ @group = options.fetch(:group, :others)
15
15
  end
16
16
 
17
17
  def <=>(other)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ez
4
4
  module Permissions
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ez-permissions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk