Class: SakaiInfo::AuthzRealm
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ModProps
included
Methods inherited from SakaiObject
#dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
Returns a new instance of AuthzRealm.
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
# 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
|
Instance Attribute Details
#maintain_role ⇒ Object
Returns the value of attribute maintain_role.
184
185
186
|
# File 'lib/sakai-info/authz.rb', line 184
def maintain_role
@maintain_role
end
|
#name ⇒ Object
Returns the value of attribute name.
184
185
186
|
# File 'lib/sakai-info/authz.rb', line 184
def name
@name
end
|
#providers ⇒ Object
Returns the value of attribute providers.
184
185
186
|
# File 'lib/sakai-info/authz.rb', line 184
def providers
@providers
end
|
Class Method Details
.all_serializations ⇒ Object
324
325
326
327
328
329
330
331
|
# File 'lib/sakai-info/authz.rb', line 324
def self.all_serializations
[
:default,
:mod,
:roles,
:users,
]
end
|
.clear_cache ⇒ Object
192
193
194
|
# File 'lib/sakai-info/authz.rb', line 192
def self.clear_cache
@@cache = {}
end
|
.find(id_or_name) ⇒ Object
.find!(id_or_name) ⇒ Object
.find_by_id(id) ⇒ Object
230
231
232
233
234
235
236
237
238
239
240
241
|
# 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) ⇒ Object
243
244
245
246
247
248
249
250
251
252
253
|
# 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) ⇒ Object
282
283
284
|
# 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) ⇒ Object
286
287
288
|
# 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
|
Instance Method Details
#default_serialization ⇒ Object
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# 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
|
#roles_serialization ⇒ Object
312
313
314
315
316
|
# File 'lib/sakai-info/authz.rb', line 312
def roles_serialization
{
"roles" => self.realm_roles.collect { |rr| rr.serialize(:realm_summary) }
}
end
|
#summary_serialization ⇒ Object
305
306
307
308
309
310
|
# File 'lib/sakai-info/authz.rb', line 305
def summary_serialization
{
"id" => self.id,
"name" => self.name,
}
end
|
#to_s ⇒ Object
218
219
220
|
# File 'lib/sakai-info/authz.rb', line 218
def to_s
name
end
|
#users_serialization ⇒ Object
318
319
320
321
322
|
# File 'lib/sakai-info/authz.rb', line 318
def users_serialization
{
"users" => self.users.collect { |u| u.serialize(:realm_summary) }
}
end
|