role_authorization 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -87,7 +87,7 @@ module RoleAuthorization
87
87
  end
88
88
 
89
89
  if creations.nil?
90
- scoped_roles
90
+ scoped_roles.flatten.uniq
91
91
  else
92
92
  creations.map do |creation|
93
93
  scoped_roles & RoleAuthorization::Roles.creations[creation]
@@ -82,6 +82,26 @@ 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)
89
+ self.serialized_roles ||= Hash.new
90
+
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
100
+ end
101
+
102
+ role_names.map {|role_name| enroll(role_name, scope)}
103
+ end
104
+
85
105
  # adds a role to the user
86
106
  def enroll(role_name, scope = nil)
87
107
  return true if has_role?(role_name.to_sym, scope)
@@ -1,3 +1,3 @@
1
1
  module RoleAuthorization
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
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.7
4
+ version: 0.5.8
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: &12152060 !ruby/object:Gem::Requirement
16
+ requirement: &22356720 !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: *12152060
24
+ version_requirements: *22356720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rr
27
- requirement: &12151640 !ruby/object:Gem::Requirement
27
+ requirement: &22356300 !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: *12151640
35
+ version_requirements: *22356300
36
36
  description: A gem for handling authorization in rails using roles
37
37
  email:
38
38
  - machinist@asceth.com