role_core 0.0.11 → 0.0.12

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
- SHA1:
3
- metadata.gz: ea0cbcc5a32c18136f5916bf1e58639590304226
4
- data.tar.gz: a66fd20532ea7c6504b279da9d3d540cf5860f11
2
+ SHA256:
3
+ metadata.gz: 161464a27b8e4e9f59ca62b95a6c975fec056196b48d1fe0a80e2d15618a368e
4
+ data.tar.gz: 28f2cc4b103d2093893ce45a98ab91e63e878e4639889822eae5e710286660d3
5
5
  SHA512:
6
- metadata.gz: f4115f302c5cfb3c96db4c2c0b136c62b99b3cd9e6bf024dc043edab1964ae6325f7c5fb9afcb4c5a03945c100fe70126cafb9a1c89170c1b83b6b58c2c662f4
7
- data.tar.gz: fe55fc4129c60e27a5bf793ea8cc62ee497de1c50e727b350faa3cec1347d49b68df59609c01625d2bf3ded089e99cf69c3b8e1bab2968ff0e235f99a2253c9c
6
+ metadata.gz: 4aaf5fe44a10e9448faec6c6ba0316ba446641238bd3c1d2e99fd29a950d43398e56ce1483edb7c0cb63d597fcccbf71dddb27aecd5e89e4dc0b3a6bb0999298
7
+ data.tar.gz: 4a85faabeeccdd1b4b84459be9aea41459972edddddac5ce6dbcbb190084304f405380496cd731cf446ea2ae37a55ae04f02301b64e27fe997fa06e2b6d71412
data/README.md CHANGED
@@ -3,6 +3,8 @@ RoleCore
3
3
 
4
4
  A Rails engine providing essential industry of Role-based access control.
5
5
 
6
+ <img width="550" alt="2018-03-12 10 12 21" src="https://user-images.githubusercontent.com/5518/37262401-e6c9d604-25dd-11e8-849d-7f7d923d5f18.png">
7
+
6
8
  ## Usage
7
9
 
8
10
  See demo for now.
@@ -18,7 +20,7 @@ gem 'role_core'
18
20
  Or you may want to include the gem directly from GitHub:
19
21
 
20
22
  ```ruby
21
- gem 'role_core', github: 'jasl-lab/role_core'
23
+ gem 'role_core', github: 'rails-engine/role_core'
22
24
  ```
23
25
 
24
26
  And then execute:
@@ -44,7 +46,7 @@ $ bin/rails db:migrate
44
46
  Clone the repository.
45
47
 
46
48
  ```sh
47
- $ git clone https://github.com/jasl/role_core.git
49
+ $ git clone https://github.com/rails-engine/role_core.git
48
50
  ```
49
51
 
50
52
  Change directory
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RoleCore
4
+ class CanCanCanPermission < RoleCore::Permission
5
+ attr_reader :action, :options
6
+
7
+ def initialize(name, priority: 0, **options, &block)
8
+ super
9
+
10
+ @model = options[:model] || options.fetch(:model_name).constantize
11
+ @action = options[:action] || name
12
+ @options = options.except(:model, :model_name, :action)
13
+ @block = block
14
+ end
15
+
16
+ def call(context, *args)
17
+ if block_attached?
18
+ context.can @action, @model, &@block.curry[*args]
19
+ else
20
+ context.can @action, @model, @options
21
+ end
22
+ end
23
+
24
+ def block_attached?
25
+ !!@block
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RoleCore
4
- VERSION = "0.0.11"
4
+ VERSION = "0.0.12"
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.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-10 00:00:00.000000000 Z
11
+ date: 2018-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -60,13 +60,14 @@ files:
60
60
  - lib/role_core.rb
61
61
  - lib/role_core/computed_permissions.rb
62
62
  - lib/role_core/concerns/models/role.rb
63
+ - lib/role_core/contrib/can_can_can_permission.rb
63
64
  - lib/role_core/engine.rb
64
65
  - lib/role_core/mapper.rb
65
66
  - lib/role_core/permission.rb
66
67
  - lib/role_core/permission_set.rb
67
68
  - lib/role_core/version.rb
68
69
  - lib/tasks/role_core_tasks.rake
69
- homepage: https://github.com/jasl-lab/role_core
70
+ homepage: https://github.com/rails-engine/role_core
70
71
  licenses:
71
72
  - MIT
72
73
  metadata: {}
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  requirements: []
88
89
  rubyforge_project:
89
- rubygems_version: 2.6.12
90
+ rubygems_version: 2.7.6
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: A Rails engine providing essential industry of Role-based access control