role_authorization 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,24 +82,23 @@ module RoleAuthorization
82
82
  enroll(value)
83
83
  end
84
84
 
85
- # mass enroll based on scope
86
- def roles=(role_names, scope = nil)
87
- # first get rid of all scoped roles
88
- scope_key, scope_id = scope_with(scope)
85
+ def global_roles
86
+ roles(:global)
87
+ end
88
+
89
+ # mass enroll, global only
90
+ def global_roles=(role_names)
91
+ # first get rid of all global roles
92
+ removed_roles = []
93
+
89
94
  self.serialized_roles ||= Hash.new
90
95
 
91
- if scope_key.nil?
92
- self.serialized_roles[:global] = Array.new
93
- else
94
- if scope_id.nil?
95
- self.serialized_roles[scope_key] = Array.new
96
- else
97
- self.serialized_roles[scope_key] ||= Hash.new
98
- self.serialized_roles[scope_key][scope_id] = Array.new
99
- end
96
+ (self.serialized_roles[:global] || []).map do |role_name|
97
+ RoleAuthorization::Roles.manager.klass.find_by_name(role_name).remove_user(self.id)
100
98
  end
99
+ self.serialized_roles[:global] = Array.new
101
100
 
102
- role_names.map {|role_name| enroll(role_name, scope)}
101
+ role_names.map {|role_name| enroll(role_name.to_s)}
103
102
  end
104
103
 
105
104
  # adds a role to the user
@@ -1,3 +1,3 @@
1
1
  module RoleAuthorization
2
- VERSION = "0.5.8"
2
+ VERSION = "0.5.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &22356720 !ruby/object:Gem::Requirement
16
+ requirement: &23450000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *22356720
24
+ version_requirements: *23450000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &22356300 !ruby/object:Gem::Requirement
27
+ requirement: &23449580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *22356300
35
+ version_requirements: *23449580
36
36
  description: A gem for handling authorization in rails using roles
37
37
  email:
38
38
  - machinist@asceth.com