role_authorization 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,6 +34,18 @@ module RoleAuthorization
34
34
  end
35
35
  end
36
36
 
37
+ def scope_ids_from(*roles)
38
+ (serialized_roles || {}).inject([]) do |array, (key, value)|
39
+ next if key == :global
40
+ next unless value.is_a?(Hash)
41
+
42
+ value.each_pair do |key, value|
43
+ array << key.to_i unless (value & roles).empty?
44
+ end
45
+ array
46
+ end
47
+ end
48
+
37
49
  def roles(scope = nil)
38
50
  scope, scope_id = scope_with(scope)
39
51
 
@@ -56,6 +68,10 @@ module RoleAuthorization
56
68
  roles(scope).include?(role)
57
69
  end
58
70
 
71
+ def <<(value)
72
+ enroll(value)
73
+ end
74
+
59
75
  # adds a role to the user
60
76
  def enroll(role_name, scope = nil)
61
77
  return true if has_role?(role_name.to_sym, scope)
@@ -1,3 +1,3 @@
1
1
  module RoleAuthorization
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
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.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - John 'asceth' Long