class SakaiInfo::AuthzFunction
Attributes
name[R]
Public Class Methods
clear_cache()
click to toggle source
# File lib/sakai-info/authz.rb, line 101 def self.clear_cache @@cache = {} end
count_by_realm_id_and_role_id(realm_id, role_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 166 def self.count_by_realm_id_and_role_id(realm_id, role_id) AuthzFunction.query_by_realm_id_and_role_id(realm_id, role_id).count end
find(id_or_name)
click to toggle source
# File lib/sakai-info/authz.rb, line 145 def self.find(id_or_name) id_or_name = id_or_name.to_s function = nil begin function = AuthzFunction.find_by_name(id_or_name) rescue ObjectNotFoundException # just in case function = AuthzFunction.find_by_id(id_or_name) end if function.nil? raise ObjectNotFoundException.new(AuthzFunction, id_or_name) end function end
find_by_id(id)
click to toggle source
# File lib/sakai-info/authz.rb, line 117 def self.find_by_id(id) id = id.to_s if @@cache[id].nil? row = DB.connect[:sakai_realm_function].where(:function_key => id.to_i).first if row.nil? raise ObjectNotFoundException.new(AuthzFunction, id) end @@cache[id] = AuthzFunction.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 130 def self.find_by_name(name) if name.nil? raise ObjectNotFoundException.new(AuthzFunction, "") end if @@cache[name].nil? row = DB.connect[:sakai_realm_function].where(:function_name => name).first if row.nil? raise ObjectNotFoundException.new(AuthzFunction, name) end @@cache[name] = AuthzFunction.new(row) @@cache[@@cache[name].id] = @@cache[name] end @@cache[name] end
find_by_realm_id_and_role_id(realm_id, role_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 170 def self.find_by_realm_id_and_role_id(realm_id, role_id) AuthzFunction.query_by_realm_id_and_role_id(realm_id, role_id). order(:function_name).all.collect { |row| AuthzFunction.new(row) } end
new(dbrow)
click to toggle source
# File lib/sakai-info/authz.rb, line 106 def initialize(dbrow) @dbrow = dbrow @id = @dbrow[:function_key].to_i @name = @dbrow[:function_name] end
query_by_realm_id_and_role_id(realm_id, role_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 160 def self.query_by_realm_id_and_role_id(realm_id, role_id) DB.connect[:sakai_realm_function]. where(:function_key => DB.connect[:sakai_realm_rl_fn].select(:function_key). where(:realm_key => realm_id, :role_key => role_id)) end
Public Instance Methods
default_serialization()
click to toggle source
# File lib/sakai-info/authz.rb, line 175 def default_serialization { "id" => self.id, "name" => self.name, } end
to_s()
click to toggle source
# File lib/sakai-info/authz.rb, line 113 def to_s name end