Class: UserCollection
- Inherits:
-
Hash
- Object
- Hash
- UserCollection
- Defined in:
- lib/kuality-coeus/data_objects/user.rb
Instance Method Summary collapse
-
#era_commons_user(username) ⇒ Object
This is a short cut to “knowing” which user can be used as a PI for a Grants.gov proposal.
-
#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
#era_commons_user(username) ⇒ Object
This is a short cut to “knowing” which user can be used as a PI for a Grants.gov proposal. At some point this should be eliminated–as in, when we know better what exactly a grants.gov PI requires.
35 36 37 |
# File 'lib/kuality-coeus/data_objects/user.rb', line 35 def era_commons_user(username) self.find{ |user| user[1][:era_commons_user_name]==username }[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 |