class SakaiInfo::AuthzRealm
Attributes
maintain_role[R]
name[R]
providers[R]
Public Class Methods
all_serializations()
click to toggle source
# File lib/sakai-info/authz.rb, line 324 def self.all_serializations [ :default, :mod, :roles, :users, ] end
clear_cache()
click to toggle source
# File lib/sakai-info/authz.rb, line 192 def self.clear_cache @@cache = {} end
find(id_or_name)
click to toggle source
# File lib/sakai-info/authz.rb, line 255 def self.find(id_or_name) id_or_name = id_or_name.to_s realm = nil begin realm = AuthzRealm.find_by_name(id_or_name) rescue ObjectNotFoundException # just in case realm = AuthzRealm.find_by_id(id_or_name) end if realm.nil? raise ObjectNotFoundException.new(AuthzRealm, id_or_name) end realm end
find!(id_or_name)
click to toggle source
# File lib/sakai-info/authz.rb, line 270 def self.find!(id_or_name) begin realm = AuthzRealm.find(id_or_name) rescue ObjectNotFoundException => e if e.classname == AuthzRealm.name realm = MissingAuthzRealm.find(id_or_name) end end realm end
find_by_id(id)
click to toggle source
# File lib/sakai-info/authz.rb, line 230 def self.find_by_id(id) id = id.to_s if @@cache[id].nil? row = DB.connect[:sakai_realm].where(:realm_key => id.to_i).first if row.nil? raise ObjectNotFoundException.new(AuthzRealm, id) end @@cache[id] = AuthzRealm.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 243 def self.find_by_name(name) if @@cache[name].nil? row = DB.connect[:sakai_realm].where(:realm_id => name).first if row.nil? raise ObjectNotFoundException.new(AuthzRealm, name) end @@cache[name] = AuthzRealm.new(row) @@cache[@@cache[name].id] = @@cache[name] end @@cache[name] end
find_by_site_id(site_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 282 def self.find_by_site_id(site_id) AuthzRealm.find_by_name("/site/#{site_id}") end
find_by_site_id_and_group_id(site_id, group_id)
click to toggle source
# File lib/sakai-info/authz.rb, line 286 def self.find_by_site_id_and_group_id(site_id, group_id) AuthzRealm.find_by_name("/site/#{site_id}/group/#{group_id}") end
new(row)
click to toggle source
# File lib/sakai-info/authz.rb, line 197 def initialize(row) @dbrow = row @id = @dbrow[:realm_key].to_i @name = @dbrow[:realm_id] if @dbrow[:provider_id].nil? @providers = nil else @providers = @dbrow[:provider_id].split("+") end if @dbrow[:maintain_role].nil? or @dbrow[:maintain_role] == "" @maintain_role = nil else @maintain_role = AuthzRole.find_by_id(@dbrow[:maintain_role]) end end
Public Instance Methods
default_serialization()
click to toggle source
# File lib/sakai-info/authz.rb, line 290 def default_serialization result = { "id" => self.id, "name" => self.name, "user_count" => self.user_count, } if not self.providers.nil? result["providers"] = self.providers end if not self.maintain_role.nil? result["maintain_role"] = self.maintain_role.name end result end
realm_roles()
click to toggle source
# File lib/sakai-info/authz.rb, line 214 def realm_roles @realm_roles ||= AuthzRealmRole.find_by_realm_id(self.id) end
roles_serialization()
click to toggle source
# File lib/sakai-info/authz.rb, line 312 def roles_serialization { "roles" => self.realm_roles.collect { |rr| rr.serialize(:realm_summary) } } end
summary_serialization()
click to toggle source
# File lib/sakai-info/authz.rb, line 305 def summary_serialization { "id" => self.id, "name" => self.name, } end
to_s()
click to toggle source
# File lib/sakai-info/authz.rb, line 218 def to_s name end
user_count()
click to toggle source
# File lib/sakai-info/authz.rb, line 222 def user_count @user_count ||= AuthzRealmMembership.count_by_realm_id(self.id) end
users()
click to toggle source
# File lib/sakai-info/authz.rb, line 226 def users @users ||= AuthzRealmMembership.find_by_realm_id(self.id) end
users_serialization()
click to toggle source
# File lib/sakai-info/authz.rb, line 318 def users_serialization { "users" => self.users.collect { |u| u.serialize(:realm_summary) } } end