Class: UserYamlCollection
- Inherits:
-
Hash
- Object
- Hash
- UserYamlCollection
- Defined in:
- lib/kuality-coeus/data_objects/user/user.rb
Overview
This is a special collection class that inherits from Hash and contains the user information listed in the users.yml file.
Instance Method Summary collapse
-
#grants_gov_pi ⇒ Object
Note: This method returns the username of a matching user record.
-
#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
Note: This method returns the username of a matching user record. It does NOT return an array of all matching users.
74 75 76 77 78 79 80 |
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 74 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.
46 47 48 |
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 46 def have_role(role) self.find_all{|user| user[1][:rolez] != nil && user[1][:rolez].detect{|r| r[:name]==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.
60 61 62 |
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 60 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.
53 54 55 |
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 53 def with_campus_code(code) self.find_all{|user| user[1][:campus_code]==code }.shuffle end |
#with_employee_type(type) ⇒ Object
64 65 66 |
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 64 def with_employee_type(type) self.find_all{|user| user[1][:employee_type]==type }.shuffle end |
#with_primary_dept_code(code) ⇒ Object
68 69 70 |
# File 'lib/kuality-coeus/data_objects/user/user.rb', line 68 def with_primary_dept_code(code) self.find_all{|user| user[1][:primary_dept_code]==code }.shuffle end |