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

Version Path
hydra-head-3.3.0 app/models/role_mapper.rb
hydra-head-3.2.2 app/models/role_mapper.rb
hydra-head-3.2.1 app/models/role_mapper.rb
hydra-head-3.2.0 app/models/role_mapper.rb
hydra-head-3.2.0.pre3 app/models/role_mapper.rb
hydra-head-3.2.0.pre2 app/models/role_mapper.rb
hydra-head-3.2.0.pre1 app/models/role_mapper.rb
hydra-head-3.1.5 app/models/role_mapper.rb
hydra-head-3.1.4 app/models/role_mapper.rb
hydra-head-3.1.3 app/models/role_mapper.rb
hydra-head-3.1.2 app/models/role_mapper.rb
hydra-head-3.1.1 app/models/role_mapper.rb
hydra-head-3.1.0 app/models/role_mapper.rb
hydra-head-3.1.0.rc2 app/models/role_mapper.rb
hydra-head-3.1.0.rc1 app/models/role_mapper.rb
hydra-head-3.1.0.pre5 app/models/role_mapper.rb
hydra-head-3.1.0.pre4 app/models/role_mapper.rb
hydra-head-3.1.0.pre3 app/models/role_mapper.rb
hydra-head-3.0.1 app/models/role_mapper.rb
hydra-head-3.1.0.pre2 app/models/role_mapper.rb