class SakaiInfo::AuthzRole
Attributes
name[R]
Public Class Methods
clear_cache()
click to toggle source
# File lib/sakai-info/authz.rb, line 16 def self.clear_cache @@cache = {} end
count_by_realm_id_and_function_id(realm_id, function_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 81 def self.count_by_realm_id_and_function_id(realm_id, function_id) AuthzRole.query_by_realm_id_and_function_id(realm_id, function_id).count end
find(id_or_name)
click to toggle source
# File lib/sakai-info/authz.rb, line 60 def self.find(id_or_name) id_or_name = id_or_name.to_s role = nil begin role = AuthzRole.find_by_name(id_or_name) rescue ObjectNotFoundException # just in case role = AuthzRole.find_by_id(id_or_name) end if role.nil? raise ObjectNotFoundException.new(AuthzRole, id_or_name) end role end
find_by_id(id)
click to toggle source
# File lib/sakai-info/authz.rb, line 32 def self.find_by_id(id) id = id.to_s if @@cache[id].nil? row = DB.connect[:sakai_realm_role].where(:role_key => id.to_i).first if row.nil? raise ObjectNotFoundException.new(AuthzRole, id) end @@cache[id] = AuthzRole.new(row) @@cache[@@cache[id].name] = @@cache[id] end @@cache[id] end
find_by_name(name)
click to toggle source
# File lib/sakai-info/authz.rb, line 45 def self.find_by_name(name) if name.nil? raise ObjectNotFoundException.new(AuthzRole, "") end if @@cache[name].nil? row = DB.connect[:sakai_realm_role].where(:role_name => name).first if row.nil? raise ObjectNotFoundException.new(AuthzRole, name) end @@cache[name] = AuthzRole.new(row) @@cache[@@cache[name].id] = @@cache[name] end @@cache[name] end
find_by_realm_id_and_function_id(realm_id, function_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 85 def self.find_by_realm_id_and_function_id(realm_id, function_id) AuthzRole.query_by_realm_id_and_function_id(realm_id, function_id). order(:role_name).all.collect { |row| AuthzRole.new(row) } end
new(dbrow)
click to toggle source
# File lib/sakai-info/authz.rb, line 21 def initialize(dbrow) @dbrow = dbrow @id = @dbrow[:role_key].to_i @name = @dbrow[:role_name] end
query_by_realm_id_and_function_id(realm_id, function_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 75 def self.query_by_realm_id_and_function_id(realm_id, function_id) DB.connect[:sakai_realm_role]. where(:role_key => DB.connect[:sakai_realm_rl_fn].select(:role_key). where(:realm_key => realm_id, :function_key => function_id)) end
Public Instance Methods
default_serialization()
click to toggle source
# File lib/sakai-info/authz.rb, line 90 def default_serialization { "id" => self.id, "name" => self.name, } end
to_s()
click to toggle source
# File lib/sakai-info/authz.rb, line 28 def to_s name end