Module: UCB::LDAP::AffiliationMethods

Included in:
Person
Defined in:
lib/ucb_ldap/person/affiliation_methods.rb

Instance Method Summary collapse

Instance Method Details

#affiliate?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 215

def affiliate?
  has_affiliation_of_type?(:affiliate) && !affiliate_expired?
end

#affiliate_academic_case_tracking?Boolean

Returns:

  • (Boolean)


171
172
173
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 171

def affiliate_academic_case_tracking?
  has_affiliation? 'AFFILIATE-TYPE-ACADEMIC CASE TRACKING'
end

#affiliate_advcon_alumnus?Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 191

def affiliate_advcon_alumnus?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-ALUMNUS'
end

#affiliate_advcon_attendee?Boolean

Returns:

  • (Boolean)


207
208
209
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 207

def affiliate_advcon_attendee?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-ATTENDEE'
end

#affiliate_advcon_caa_member?Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 195

def affiliate_advcon_caa_member?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-CAA-MEMBER'
end

#affiliate_advcon_friend?Boolean

Returns:

  • (Boolean)


187
188
189
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 187

def affiliate_advcon_friend?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-FRIEND'
end

#affiliate_advcon_i_house_resident?Boolean

Returns:

  • (Boolean)


199
200
201
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 199

def affiliate_advcon_i_house_resident?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-I-HOUSE-RESIDENT'
end

#affiliate_advcon_student?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 203

def affiliate_advcon_student?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-STUDENT'
end

#affiliate_advcon_trustee?Boolean

Returns:

  • (Boolean)


183
184
185
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 183

def affiliate_advcon_trustee?
  has_affiliation? 'AFFILIATE-TYPE-ADVCON-TRUSTEE'
end

#affiliate_aws_only?Boolean

Determine if the persone is an AFFILIATE #

Returns:

  • (Boolean)


99
100
101
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 99

def affiliate_aws_only?
  has_affiliation? 'AFFILIATE-TYPE-AWS ONLY'
end

#affiliate_billing_only?Boolean

Returns:

  • (Boolean)


179
180
181
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 179

def affiliate_billing_only?
  has_affiliation? 'AFFILIATE-TYPE-BILLING ONLY'
end

#affiliate_committee_member?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 135

def affiliate_committee_member?
  has_affiliation? 'AFFILIATE-TYPE-COMMITTEE MEMBER'
end

#affiliate_concurrent_enrollment?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 151

def affiliate_concurrent_enrollment?
  has_affiliation? 'AFFILIATE-TYPE-CONCURR ENROLL'
end

#affiliate_consultant?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 139

def affiliate_consultant?
  has_affiliation? 'AFFILIATE-TYPE-CONSULTANT'
end

#affiliate_contractor?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 123

def affiliate_contractor?
  has_affiliation? 'AFFILIATE-TYPE-CONTRACTOR'
end

#affiliate_departmental?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 159

def affiliate_departmental?
  has_affiliation? 'AFFILIATE-TYPE-DEPARTMENTAL'
end

#affiliate_directory_only?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 111

def affiliate_directory_only?
  has_affiliation? 'AFFILIATE-TYPE-DIRECTORY ONLY'
end

#affiliate_emeritus?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 107

def affiliate_emeritus?
  has_affiliation? 'AFFILIATE-TYPE-EMERITUS'
end

#affiliate_expiration_dateObject



219
220
221
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 219

def affiliate_expiration_date
  Date.parse(berkeleyEduAffExpDate.to_s)
end

#affiliate_expired?Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 211

def affiliate_expired?
  has_affiliation? 'AFFILIATE-STATUS-EXPIRED'
end

#affiliate_hhmi_researcher?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 147

def affiliate_hhmi_researcher?
  has_affiliation? 'AFFILIATE-TYPE-HHMI RESEARCHER'
end

#affiliate_lbl_doe_postdoc?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 127

def affiliate_lbl_doe_postdoc?
  has_affiliation? 'AFFILIATE-TYPE-LBL/DOE POSTDOC'
end

#affiliate_lbl_op_staff?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 131

def affiliate_lbl_op_staff?
  has_affiliation? 'AFFILIATE-TYPE-LBLOP STAFF'
end

#affiliate_maintenance?Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 175

def affiliate_maintenance?
  has_affiliation? 'AFFILIATE-TYPE-MAINTENANCE'
end

#affiliate_staff_affiliate?Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 167

def affiliate_staff_affiliate?
  has_affiliation? 'AFFILIATE-TYPE-STAFF-AFFILIATE'
end

#affiliate_staff_retiree?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 103

def affiliate_staff_retiree?
  has_affiliation? 'AFFILIATE-TYPE-STAFF RETIREE'
end

#affiliate_temp_agency?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 155

def affiliate_temp_agency?
  has_affiliation? 'AFFILIATE-TYPE-TEMP AGENCY'
end

#affiliate_test?Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 163

def affiliate_test?
  has_affiliation? 'AFFILIATE-TYPE-TEST'
end

#affiliate_visiting?Boolean

Note: there are actually 2 types of visting affiliaties, visiting student and visiting scholars. But for now we will generalize.

Returns:

  • (Boolean)


119
120
121
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 119

def affiliate_visiting?
  has_affiliation? 'AFFILIATE-TYPE-VISITING'
end

#affiliate_volunteer?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 143

def affiliate_volunteer?
  has_affiliation? 'AFFILIATE-TYPE-VOLUNTEER'
end

#affiliationsObject

Returns an Array of Person’s affiliations.



8
9
10
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 8

def affiliations
  @affiliations ||= berkeleyEduAffiliations.map { |a| a.upcase }
end

#employee?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 58

def employee?
  has_affiliation_of_type?(:employee) && !employee_expired?
end

#employee_academic?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 46

def employee_academic?
  has_affiliation? 'EMPLOYEE-TYPE-ACADEMIC'
end

#employee_expiration_dateObject



54
55
56
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 54

def employee_expiration_date
  Date.parse(berkeleyEduEmpExpDate.to_s)
end

#employee_expired?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 50

def employee_expired?
  has_affiliation? 'EMPLOYEE-STATUS-EXPIRED'
end

#employee_staff?Boolean

Returns true if entry has the “staff” affiliation.

Returns:

  • (Boolean)


42
43
44
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 42

def employee_staff?
  has_affiliation? 'EMPLOYEE-TYPE-STAFF'
end

#has_affiliation?(affiliation) ⇒ Boolean

Returns true if entry’s affiliations contain affiliation.

Case-insensitive.

Returns:

  • (Boolean)


17
18
19
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 17

def has_affiliation?(affiliation)
  affiliations.include?(affiliation.upcase)
end

#has_affiliation_of_type?(affiliation_type) ⇒ Boolean

Returns true if Person’s affiliations contain at least one affiliation of a particular type.

p = Person.find_by_uid ...
p.affiliations                         #=> ['EMPLOYEE-TYPE-STAFF']
p.has_affiliation_of_type?(:employee)  #=> true
p.has_affiliation_of_type?(:student)   #=> false

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 29

def has_affiliation_of_type?(affiliation_type)
  aff_type_string = affiliation_type.to_s.upcase
  affiliations.find { |a| a =~ /^#{aff_type_string}-TYPE-/ } ? true : false
end

#student?Boolean

Returns true if entry has a studend affiliation and is not expired.

Returns:

  • (Boolean)


90
91
92
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 90

def student?
  has_affiliation_of_type?(:student) && !student_expired?
end

#student_expiration_dateObject



74
75
76
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 74

def student_expiration_date
  Date.parse(berkeleyEduStuExpDate.to_s)
end

#student_expired?Boolean

Returns true if is an expired student.

Returns:

  • (Boolean)


70
71
72
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 70

def student_expired?
  has_affiliation? 'STUDENT-STATUS-EXPIRED'
end

#student_not_registered?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 82

def student_not_registered?
  has_affiliation? 'STUDENT-TYPE-NOT REGISTERED'
end

#student_registered?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 78

def student_registered?
  has_affiliation? 'STUDENT-TYPE-REGISTERED'
end