role_core 0.0.23 → 0.0.25

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: 92b7cef555bb26f6bfc874474cb7d2022439b0c1313a993fbfa8159e1d48a42d
4
- data.tar.gz: 52e099c40d613d9422e547c8d33d0f4502102798103c07704819e2088e9d518d
3
+ metadata.gz: 588687072ceb69fb165d2c7f86d8bb0dae0c814d33049221466dc4c0adcacfb0
4
+ data.tar.gz: 2c0cf9515890e0389246d4fb4f570b3f39aae95781ad616d0c6306917df25a55
5
5
  SHA512:
6
- metadata.gz: a1f2be0cfc15348bb90b40686018005611fc97bf8f64484ca5fcd56da292b01a5f524af7adaafed25e92c3e841eb1cad1216d721df8dd1cd59449b55ab9fe71c
7
- data.tar.gz: 8053a3906de716d20dfcb0ce318ca1445fade44a72ae2a32c7660d94cb0a3fa227dd9ad178de22f0c6759adbfbaccb01f5627186883d6ca1f6ec9085deb4a428
6
+ metadata.gz: 1c1419d298d3664ea384f88d68db83fd4209bda7827e826ede86c5720d170b3d83874e8df9650917a5ca93dac0ff79c4bda3a5f1e7d67c1cc292396ef46d6a14
7
+ data.tar.gz: 83d4392b01a8766946f8c1e8fd1695d481f351d24628feab71724982c0c7d883b5b691ea961e29e73809ff73974fbcaab4c1158772a392ebd8d5ae56aecf3f52
data/README.md CHANGED
@@ -47,7 +47,7 @@ Open your browser, and visit `http://localhost:3000`
47
47
 
48
48
  The essence of RBAC is the role, despite your application, there are many possibilities: single-role, multi-roles, extendable-role and the role may associate to different kinds of resources (e.g: users and groups)
49
49
 
50
- RoleCore provides a essential definition of Role,
50
+ RoleCore provides an essential definition of Role,
51
51
  you have to add association to adapt to your application,
52
52
  for example:
53
53
 
@@ -368,7 +368,7 @@ By design, RoleCore is for static permissions, but dynamic permissions is easy t
368
368
 
369
369
  The key is `RoleCore::PermissionSet#derive`, that will generate a new anonymous sub-class of `PermissionSet`.
370
370
 
371
- There's a example:
371
+ Here's an example:
372
372
 
373
373
  - Design a model to persisting dynamic permissions, e.g `DynamicPermission(id: bigint, name: string, default: bool)`
374
374
  - Add `dynamic_permissions` column (`text` type) to Role model to persisting dynamic permissions' configuration, and in your model `serialize :dynamic_permissions, Hash`
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateRoles < ActiveRecord::Migration[5.1]
2
4
  def change
3
5
  create_table :roles do |t|
@@ -9,20 +9,23 @@ module RoleCore
9
9
  return unless _callable
10
10
 
11
11
  @model_name = options[:model_name]
12
+ @subject = options[:subject]
12
13
  @action = options[:action] || name
13
- @options = options.except(:model, :model_name, :action)
14
+ @options = options.except(:model, :model_name, :subject, :action)
14
15
  @block = block
15
16
  end
16
17
 
17
18
  def call(context, *args)
18
19
  return unless callable
19
20
 
20
- model = @model_name.constantize
21
+ subject = @subject || @model_name.constantize
21
22
  if block_attached?
22
- context.can @action, model, &@block.curry[*args]
23
+ context.can @action, subject, &@block.curry[*args]
23
24
  else
24
- context.can @action, model, @options
25
+ context.can @action, subject, @options
25
26
  end
27
+ rescue NameError
28
+ raise "You must provide a valid model name."
26
29
  end
27
30
 
28
31
  def block_attached?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RoleCore
4
- VERSION = "0.0.23"
4
+ VERSION = "0.0.25"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-21 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.0'
22
+ version: '7'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,14 +29,14 @@ dependencies:
29
29
  version: '5'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.0'
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: options_model
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.0.11
39
+ version: 0.0.12
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '1.0'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.0.11
49
+ version: 0.0.12
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '1.0'
@@ -100,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.7.7
103
+ rubygems_version: 3.0.3
105
104
  signing_key:
106
105
  specification_version: 4
107
106
  summary: RoleCore is a Rails engine which could provide essential industry of Role-based