role_core 0.0.16 → 0.0.17

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: 63f9af3dc716a40099563d28bc8f409c0ae479eef42ece8ddd24fa3a90ab48c9
4
- data.tar.gz: 44e757638be123b0877bf868814f712f920b48e5b8f3bb950fc83c1e4f649a62
3
+ metadata.gz: 32110dc81e77039a694a09ff4d761751dd78e2308542672a42376d4c0660f75b
4
+ data.tar.gz: 8e6c5a01c34352ae9bff7a700cfb9c2d493b0c48e256168e32d8b517277bf1d4
5
5
  SHA512:
6
- metadata.gz: 4151358dfb0e084f9e5c3be912ba6e605610fe80ef1bce0af72c01120df8c8f9061554dc427f00fbcc611bc5050a59c512828b7b0945d128b45eaad0bfdb954f
7
- data.tar.gz: 5827598c230b815ef22ba4db1d08f21136495d96419430a5e86c92f48d9790244a8988e0712c80485c8346a01027df2066dfd60032b70e0735a0ecd3dbf3889d
6
+ metadata.gz: 0e275a6b77ed0b93c1930a4efe6e0f694e03d05c64642b2506d17a9ccc000df490dce2f9c3abc5ba941aee2702ee859214cc9436b5269a31e35b6d11885013fe
7
+ data.tar.gz: f44c84d5c76c63c860853b6d1d0aaa55be911ced977a153dce45c3b37116069fd86657b87f5bb682986f85effd6ae5428c15f9c7b47d8748e9e3f9b8a66d6e7f
@@ -1,6 +1,7 @@
1
1
  en:
2
2
  role_core:
3
3
  models: # Defined by `group` place here
4
+ # global: Global # The top-level
4
5
  # project: Projects
5
6
  # project/task: Tasks # A nested group
6
7
  attributes:
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # YOU NEED TO RESTART APP AFTER CHANGING THIS FILE
4
+
3
5
  # Uncomment below if you want to integrate with CanCanCan
4
6
  #
5
7
  # require "role_core/contrib/can_can_can_permission"
@@ -67,4 +69,9 @@ RoleCore.permission_set_class.draw do
67
69
  #
68
70
  # permission :read_public, action: :read, is_public: true
69
71
  #
72
+ # For some reason, you won't interpret the permission to CanCanCan,
73
+ # you can set `_callable: false` to `permission` or `group`
74
+ #
75
+ # permission :read, _callable: false
76
+ #
70
77
  end.finalize! # Call `finalize!` to freezing the definition, that's optional.
@@ -4,8 +4,9 @@ module RoleCore
4
4
  class CanCanCanPermission < RoleCore::Permission
5
5
  attr_reader :action, :options
6
6
 
7
- def initialize(name, _namespace: [], _priority: 0, **options, &block)
7
+ def initialize(name, _namespace: [], _priority: 0, _callable: true, **options, &block)
8
8
  super
9
+ return unless _callable
9
10
 
10
11
  @model = options[:model] || options.fetch(:model_name).constantize
11
12
  @action = options[:action] || name
@@ -14,6 +15,8 @@ module RoleCore
14
15
  end
15
16
 
16
17
  def call(context, *args)
18
+ return unless callable
19
+
17
20
  if block_attached?
18
21
  context.can @action, @model, &@block.curry[*args]
19
22
  else
@@ -2,12 +2,13 @@
2
2
 
3
3
  module RoleCore
4
4
  class Permission
5
- attr_reader :name, :namespace, :priority
5
+ attr_reader :name, :namespace, :priority, :callable
6
6
 
7
- def initialize(name, _namespace: [], _priority: 0, **options, &block)
7
+ def initialize(name, _namespace: [], _priority: 0, _callable: false, **options, &block)
8
8
  @name = name
9
9
  @namespace = _namespace
10
10
  @priority = _priority
11
+ @callable = _callable
11
12
  end
12
13
 
13
14
  def call(context, *)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RoleCore
4
- VERSION = "0.0.16"
4
+ VERSION = "0.0.17"
5
5
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # desc "Explaining what the task does"
3
4
  # task :role_core do
4
5
  # # Task goes here
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl