can_play 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 3c81ae7827dd27f109d747595eb8e96d60de3089
4
- data.tar.gz: e30b740ae3afb6b37fc1e2ed206f25da0c961d5c
3
+ metadata.gz: 7eed223e4874c108017e81a8d0502041e3022e81
4
+ data.tar.gz: 8a490f3b79ac9af3223e67f5b5ba7c6a6a9a0510
5
5
  SHA512:
6
- metadata.gz: cf442e042eba7431302500371f61e6216c7989990143ddbe6d9c291aeb94cb8ca9882cc5003cd49a71ea624be23503434e3989d54a8afdf43131fdb7d5a6d7a5
7
- data.tar.gz: 6409b25d4ee731b4cf3d8f7ebb88106a7958b746eff753d712a82cc3aae89cd5184476bb28acea62db6abcba559bc01a47dc25571f2a829b3f2ea5c77d50a1aa
6
+ metadata.gz: 3926d91df4c06593a9d521ffe5274304864a3c4fffb1fd58899ca044fe53e4cb4e2fd47e676637c38109d8a426a1aae3815ebe64055f3cabc2bb2f0b26f61192
7
+ data.tar.gz: 13d6190e996237505d67a5c4abb74b46cbb963898b287dc9967abb6cef0a488ab505e4c5e00e2ae6e17fe3da94db1a459fa84a1a00046eab12ecac565dab3838
@@ -4,9 +4,12 @@ class Ability
4
4
 
5
5
  def initialize(user)
6
6
  self.user = user||CanPlay::Config.user_class_name.constantize.new
7
+ CanPlay::Config.super_roles.each do |role_name|
8
+ can(:manage, :all) if user.role?(role_name)
9
+ end
7
10
  CanPlay::Config.role_class_name.constantize.all.each do |role|
8
11
  next unless user.role?(role.name)
9
- role.send(CanPlay::Config.role_resources_middle_class_name.underscore.pluralize).each do |role_resource|
12
+ role.send(CanPlay::Config.role_resources_relation_name).each do |role_resource|
10
13
  resource = CanPlay.find_by_name(role_resource.resource_name)
11
14
  next unless resource
12
15
  if resource[:type] == 'collection'
@@ -1,3 +1,3 @@
1
1
  module CanPlay
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/can_play.rb CHANGED
@@ -74,10 +74,11 @@ module CanPlay
74
74
  end
75
75
 
76
76
  module Config
77
- mattr_accessor :user_class_name, :role_class_name, :role_resources_middle_class_name
77
+ mattr_accessor :user_class_name, :role_class_name, :role_resources_relation_name, :super_roles
78
78
  @@user_class_name = 'User'
79
79
  @@role_class_name = 'Role'
80
- @@role_resources_middle_class_name = 'RoleResource'
80
+ @@role_resources_relation_name = 'role_resources'
81
+ @@super_roles = []
81
82
 
82
83
  def self.setup
83
84
  yield self
@@ -1,8 +1,16 @@
1
- # 在此可设置角色类名称、角色权限中间表等信息。
1
+ # 在此可设置重要配置信息。
2
2
 
3
3
  CanPlay::Config.setup do |config|
4
+
5
+ # role_class_name表示用户表表名。
4
6
  config.user_class_name = 'User'
7
+
8
+ # role_class_name表示角色表表名
5
9
  config.role_class_name = 'Role'
6
- config.role_resources_middle_class_name = 'RoleResource'
7
- config.resource_class_name = 'Resource'
10
+
11
+ # super_role_resources_relation_name表示角色和权限中间表在model中的关联名称。
12
+ config.role_resources_relation_name = 'role_resources'
13
+
14
+ # super_roles表示无需分配权限既可拥有所有权限的角色。
15
+ config.super_roles = ['超级管理员']
8
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: can_play
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - happyming9527
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-29 00:00:00.000000000 Z
11
+ date: 2015-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.4.6
126
+ rubygems_version: 2.4.8
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: a permission system.