role_authorization 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,30 +48,34 @@ module RoleAuthorization
48
48
  end
49
49
  end
50
50
 
51
- def roles(scope = nil)
52
- scope, scope_id = scope_with(scope)
51
+ def roles(scopes = nil)
52
+ scopes = [scopes] unless scopes.is_a? Array
53
53
 
54
- (serialized_roles || {}).inject([]) do |array, (key, value)|
55
- if key == :global && scope.nil?
56
- array << value
57
- else
58
- if scope.nil? || (key == scope.to_sym && scope_id.nil?)
59
- if value.is_a?(Hash)
60
- array << value.values
61
- else
62
- array << value unless value.nil?
63
- end
54
+ scopes.map do |scope|
55
+ scope, scope_id = scope_with(scope)
56
+
57
+ (serialized_roles || {}).inject([]) do |array, (key, value)|
58
+ if key == :global && scope.nil?
59
+ array << value
64
60
  else
61
+ if scope.nil? || (key == scope.to_sym && scope_id.nil?)
62
+ if value.is_a?(Hash)
63
+ array << value.values
64
+ else
65
+ array << value unless value.nil?
66
+ end
67
+ else
65
68
  array << value[scope_id] unless scope_id.nil?
69
+ end
66
70
  end
67
- end
68
71
 
69
- array
72
+ array
73
+ end
70
74
  end.flatten.uniq
71
75
  end
72
76
 
73
- def has_role?(role, scope = nil)
74
- roles(scope).include?(role)
77
+ def has_role?(role, scopes = nil)
78
+ roles(scopes).include?(role)
75
79
  end
76
80
 
77
81
  def <<(value)
@@ -1,3 +1,3 @@
1
1
  module RoleAuthorization
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: role_authorization
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.2
5
+ version: 0.5.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - John 'asceth' Long