@@ -33,15 +33,43 @@ module Net
3333class LDAP
3434
3535
36+ # Objects of this class represent individual entries in an LDAP
37+ # directory. User code generally does not instantiate this class.
38+ # Net::LDAP#search provides objects of this class to user code,
39+ # either as block parameters or as return values.
40+ #
41+ # In LDAP-land, an "entry" is a collection of attributes that are
42+ # uniquely and globally identified by a DN ("Distinguished Name").
43+ # Attributes are identified by short, descriptive words or phrases.
44+ # Although a directory is
45+ # free to implement any attribute name, most of them follow rigorous
46+ # standards so that the range of commonly-encountered attribute
47+ # names is not large.
48+ #
49+ # An attribute name is case-insensitive. Most directories also
50+ # restrict the range of characters allowed in attribute names.
51+ # To simplify handling attribute names, Net::LDAP::Entry
52+ # internally converts them to a standard format. Therefore, the
53+ # methods which take attribute names can take Strings or Synmbols,
54+ # and work correctly regardless of case or capitalization.
55+ #
56+ # An attribute consists of zero or more data items called
57+ # <i>values.</i> An entry is the combination of a unique DN, a set of attribute
58+ # names, and a (possibly-empty) array of values for each attribute.
59+ #
60+ # Class Net::LDAP::Entry provides convenience methods for dealing
61+ # with LDAP entries.
62+ #
3663 class Entry
3764
38- def initialize dn = nil
65+ # This constructor is not generally called by user code.
66+ def initialize dn = nil # :nodoc:
3967 @myhash = Hash . new { |k , v | k [ v ] = [ ] }
4068 @myhash [ :dn ] = [ dn ]
4169 end
4270
4371
44- def []= name , value
72+ def []= name , value # :nodoc:
4573 sym = name . to_s . downcase . intern
4674 @myhash [ sym ] = value
4775 end
@@ -52,22 +80,33 @@ def []= name, value
5280 # because this one and not the other one gets called
5381 # in formulations like entry["CN"] << cn.
5482 #
55- def [] name
83+ def [] name # :nodoc:
5684 name = name . to_s . downcase . intern unless name . is_a? ( Symbol )
5785 @myhash [ name ]
5886 end
5987
88+ # Returns the dn of the Entry as a String.
6089 def dn
6190 self [ :dn ] [ 0 ]
6291 end
6392
93+ # Returns an array of the attribute names present in the Entry.
6494 def attribute_names
6595 @myhash . keys
6696 end
6797
98+ # Accesses each of the attributes present in the Entry.
99+ # Calls a user-supplied block with each attribute in turn,
100+ # passing two arguments to the block: a Symbol giving
101+ # the name of the attribute, and a (possibly empty)
102+ # Array of data values.
103+ #
68104 def each
69105 if block_given?
70- attribute_names . each { |a | yield a , self [ a ] }
106+ attribute_names . each { |a |
107+ attr_name , values = a , self [ a ]
108+ yield attr_name , values
109+ }
71110 end
72111 end
73112
0 commit comments