Sha256: 39c478661c2893266f42119cd64eeb35add457df3dd7fda4b54a0c755078bf5e
Contents?: true
Size: 434 Bytes
Versions: 28
Compression:
Stored size: 434 Bytes
Contents
require 'yaml' class RoleMapper @@map = YAML.load(File.open(File.join(Rails.root, "config/role_map_#{Rails.env}.yml"))) m = Hash.new{|h,k| h[k]=[]} @@byname = @@map.inject(m) do|memo, k| k.last.each { |x| memo[x]<<k.first} memo end class << self def role_names @@map.keys end def roles(username) @@byname[username]||[] end def whois(r) @@map[r]||[] end end end
Version data entries
28 entries across 28 versions & 1 rubygems