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,
    :email => :mail,
    :orgs => :berkeleyEduPrimaryDeptUnitHierarchyString
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ldap_entry) ⇒ Person

Returns a new instance of Person.



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

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



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

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

Instance Method Details

#<=>(other_person) ⇒ Object



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

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

#eql?(other_person) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#full_nameObject



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

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

#hashObject



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

def hash
  self.uid.to_i
end