Class: SakaiInfo::AuthzRealmMembership
- Inherits:
-
SakaiObject
- Object
- SakaiObject
- SakaiInfo::AuthzRealmMembership
- Defined in:
- lib/sakai-info/authz.rb
Instance Attribute Summary collapse
-
#realm ⇒ Object
readonly
Returns the value of attribute realm.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Attributes inherited from SakaiObject
Class Method Summary collapse
- .count_by_realm_id(realm_id) ⇒ Object
- .find_by_realm_id(realm_id) ⇒ Object
- .find_by_user_id(user_id) ⇒ Object
Instance Method Summary collapse
-
#initialize(realm_id, user_id, role) ⇒ AuthzRealmMembership
constructor
A new instance of AuthzRealmMembership.
Methods inherited from SakaiObject
all_serializations, #dbrow_only_serialization, #dbrow_serialization, #default_serialization, #object_type_serialization, #serialize, #to_json, #to_yaml
Constructor Details
#initialize(realm_id, user_id, role) ⇒ AuthzRealmMembership
Returns a new instance of AuthzRealmMembership.
326 327 328 329 330 |
# File 'lib/sakai-info/authz.rb', line 326 def initialize(realm_id, user_id, role) @realm = AuthzRealm.find(realm_id) @user = User.find(user_id) @role = AuthzRole.find(role) end |
Instance Attribute Details
#realm ⇒ Object (readonly)
Returns the value of attribute realm.
324 325 326 |
# File 'lib/sakai-info/authz.rb', line 324 def realm @realm end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
324 325 326 |
# File 'lib/sakai-info/authz.rb', line 324 def role @role end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
324 325 326 |
# File 'lib/sakai-info/authz.rb', line 324 def user @user end |
Class Method Details
.count_by_realm_id(realm_id) ⇒ Object
344 345 346 |
# File 'lib/sakai-info/authz.rb', line 344 def self.count_by_realm_id(realm_id) DB.connect[:sakai_realm_rl_gr].filter(:realm_key => realm_id).count end |
.find_by_realm_id(realm_id) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/sakai-info/authz.rb', line 332 def self.find_by_realm_id(realm_id) results = [] DB.connect.fetch("select srrg.user_id as user_id, " + "srr.role_name as role_name " + "from sakai_realm_rl_gr srrg, sakai_realm_role srr " + "where srrg.role_key = srr.role_key " + "and srrg.realm_key = ?", realm_id) do |row| results << AuthzRealmMembership.new(realm_id, row[:user_id], row[:role_name]) end results end |
.find_by_user_id(user_id) ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/sakai-info/authz.rb', line 348 def self.find_by_user_id(user_id) results = [] DB.connect.fetch("select sr.realm_id as realm_id, " + "srr.role_name as role_name " + "from sakai_realm_rl_gr srrg, sakai_realm_role srr, sakai_realm sr " + "where srrg.role_key = srr.role_key " + "and srrg.realm_key = sr.realm_key " + "and srrg.user_id = ?", user_id) do |row| results << AuthzRealmMembership.new(row[:realm_id], user_id, row[:role_name]) end results end |