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)


217
218
219
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 217

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

#affiliate_academic_case_tracking?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 173

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

#affiliate_advcon_alumnus?Boolean

Returns:

  • (Boolean)


193
194
195
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 193

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

#affiliate_advcon_attendee?Boolean

Returns:

  • (Boolean)


209
210
211
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 209

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

#affiliate_advcon_caa_member?Boolean

Returns:

  • (Boolean)


197
198
199
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 197

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

#affiliate_advcon_friend?Boolean

Returns:

  • (Boolean)


189
190
191
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 189

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

#affiliate_advcon_i_house_resident?Boolean

Returns:

  • (Boolean)


201
202
203
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 201

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

#affiliate_advcon_student?Boolean

Returns:

  • (Boolean)


205
206
207
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 205

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

#affiliate_advcon_trustee?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 185

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

#affiliate_aws_only?Boolean

Determine if the persone is an AFFILIATE #

Returns:

  • (Boolean)


101
102
103
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 101

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

#affiliate_billing_only?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 181

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

#affiliate_committee_member?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 137

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

#affiliate_concurrent_enrollment?Boolean

Returns:

  • (Boolean)


153
154
155
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 153

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

#affiliate_consultant?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 141

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

#affiliate_contractor?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 125

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

#affiliate_departmental?Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 161

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

#affiliate_directory_only?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 113

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

#affiliate_emeritus?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 109

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

#affiliate_expiration_dateObject



221
222
223
224
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 221

def affiliate_expiration_date
  warn "DEPRECATED: affiliate_expiration_date is no longer supported"
  nil
end

#affiliate_expired?Boolean

Returns:

  • (Boolean)


213
214
215
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 213

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

#affiliate_hhmi_researcher?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 149

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

#affiliate_lbl_doe_postdoc?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 129

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

#affiliate_lbl_op_staff?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 133

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

#affiliate_maintenance?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 177

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

#affiliate_staff_affiliate?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 169

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

#affiliate_staff_retiree?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 105

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

#affiliate_temp_agency?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 157

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

#affiliate_test?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 165

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)


121
122
123
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 121

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

#affiliate_volunteer?Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 145

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)


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

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
57
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 54

def employee_expiration_date
  warn "DEPRECATED: employee_expiration_date is no longer supported"
  nil
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)


92
93
94
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 92

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

#student_expiration_dateObject



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

def student_expiration_date
  warn "DEPRECATED: student_expiration_date is no longer supported"
  nil
end

#student_expired?Boolean

Returns true if is an expired student.

Returns:

  • (Boolean)


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

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

#student_not_registered?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 84

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

#student_registered?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/ucb_ldap/person/affiliation_methods.rb', line 80

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