Module: Hydra::RoleMapperBehavior::ClassMethods
- Defined in:
- lib/hydra/role_mapper_behavior.rb
Instance Method Summary collapse
- #byname ⇒ Object
- #fetch_groups(user:) ⇒ Object
- #map ⇒ Object
- #role_names ⇒ Object
-
#roles(user_or_uid) ⇒ Object
If you pass in a nil User object (ie. user isn’t logged in), or a uid that doesn’t exist, it will return an empty array.
- #whois(r) ⇒ Object
Instance Method Details
#byname ⇒ Object
37 38 39 40 41 |
# File 'lib/hydra/role_mapper_behavior.rb', line 37 def byname @byname ||= map.each_with_object(Hash.new{ |h,k| h[k] = [] }) do |(role, usernames), memo| Array(usernames).each { |x| memo[x] << role} end end |
#fetch_groups(user:) ⇒ Object
10 11 12 |
# File 'lib/hydra/role_mapper_behavior.rb', line 10 def fetch_groups(user:) _groups(user.user_key) end |
#map ⇒ Object
32 33 34 |
# File 'lib/hydra/role_mapper_behavior.rb', line 32 def map @map ||= load_role_map end |
#role_names ⇒ Object
6 7 8 |
# File 'lib/hydra/role_mapper_behavior.rb', line 6 def role_names map.keys end |
#roles(user_or_uid) ⇒ Object
If you pass in a nil User object (ie. user isn’t logged in), or a uid that doesn’t exist, it will return an empty array
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hydra/role_mapper_behavior.rb', line 17 def roles(user_or_uid) Deprecation.warn(self, "roles is deprecated and will be removed in Hydra-Head 11. Use fetch_groups instead") user_id = case user_or_uid when String user_or_uid else user_or_uid.user_key end _groups(user_id) end |
#whois(r) ⇒ Object
28 29 30 |
# File 'lib/hydra/role_mapper_behavior.rb', line 28 def whois(r) map[r] || [] end |