Class: UserCollection
- Inherits:
-
Hash
- Object
- Hash
- UserCollection
- Defined in:
- lib/kuality-coeus/data_objects/user.rb
Instance Method Summary collapse
- #grants_gov_pi ⇒ Object
-
#have_role(role) ⇒ Object
Returns an array of all users with the specified role.
-
#with_affiliation_type(type) ⇒ Object
Returns an array of all users with the specified affiliation type.
-
#with_campus_code(code) ⇒ Object
Returns an array of all users with the specified campus code.
- #with_employee_type(type) ⇒ Object
- #with_primary_dept_code(code) ⇒ Object
Instance Method Details
#grants_gov_pi ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 32 def grants_gov_pi self.find_all { |user| !user[1][:primary_department_code].nil? && !user[1][:phones].find{|phone| phone[:type]=='Work'}.nil? && !user[1][:emails].find{|email| email[:type]=='Work'}.nil? && !user[1][:era_commons_user_name].nil? }.shuffle[0][0] end |
#have_role(role) ⇒ Object
Returns an array of all users with the specified role. Takes the role name as a string. The array is shuffled so that #have_role(‘role name’) will be a random selection from the list of matching users.
6 7 8 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 6 def have_role(role) self.find_all{|user| user[1][:roles] != nil && user[1][:roles].include?(role)}.shuffle end |
#with_affiliation_type(type) ⇒ Object
Returns an array of all users with the specified affiliation type. Takes the type name as a string. The array is shuffled so that #with_affiliation_type(‘type name’) will be a random selection from the list of matching users.
20 21 22 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 20 def with_affiliation_type(type) self.find_all{|user| user[1][:affiliation_type]==type }.shuffle end |
#with_campus_code(code) ⇒ Object
Returns an array of all users with the specified campus code. Takes the code as a string. The array is shuffled so that #with_campus_code(‘code’) will be a random selection from the list of matching users.
13 14 15 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 13 def with_campus_code(code) self.find_all{|user| user[1][:campus_code]==code }.shuffle end |
#with_employee_type(type) ⇒ Object
24 25 26 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 24 def with_employee_type(type) self.find_all{|user| user[1][:employee_type]==type }.shuffle end |
#with_primary_dept_code(code) ⇒ Object
28 29 30 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 28 def with_primary_dept_code(code) self.find_all{|user| user[1][:primary_dept_code]==code }.shuffle end |