Class: UcbGroups::Person

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/ucb_groups/person.rb

Constant Summary collapse

ATTRIBUTE_MAPPINGS =
{
    :uid => :uid,
    :first_name => :givenname,
    :last_name => :sn,
    :public_email => :mail,
    :official_email => :ucbemail,
    :orgs => :berkeleyEduPrimaryDeptUnitHierarchyString
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ldap_entry) ⇒ Person

Returns a new instance of Person.



16
17
18
19
20
# File 'lib/ucb_groups/person.rb', line 16

def initialize(ldap_entry)
  ATTRIBUTE_MAPPINGS.each do |attr, val|
    self.send("#{attr}=", ldap_entry[val].first.to_s) if ldap_entry[val]
  end
end

Class Method Details

.ldap_attributesObject



26
27
28
# File 'lib/ucb_groups/person.rb', line 26

def self.ldap_attributes
  @ldap_attributes ||= ATTRIBUTE_MAPPINGS.values.map(&:to_s)
end

Instance Method Details

#<=>(other_person) ⇒ Object



38
39
40
# File 'lib/ucb_groups/person.rb', line 38

def <=>(other_person)
  self.hash <=> other_person.hash
end

#eql?(other_person) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ucb_groups/person.rb', line 30

def eql?(other_person)
  self.hash == other_person.hash
end

#full_nameObject



22
23
24
# File 'lib/ucb_groups/person.rb', line 22

def full_name
  [first_name, last_name].join(" ")
end

#hashObject



34
35
36
# File 'lib/ucb_groups/person.rb', line 34

def hash
  self.uid.to_i
end