Parent

Included Modules

Class Index [+]

Quicksearch

ActiveLdap::DistinguishedName

Attributes

rdns[R]

Public Class Methods

escape_value(value) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 161
161:       def escape_value(value)
162:         if /(\A | \z)/.match(value)
163:           '"' + value.gsub(/([\\\"])/, '\\\1') + '"'
164:         else
165:           value.gsub(/([,=\+<>#;\\\"])/, '\\\1')
166:         end
167:       end
new(*rdns) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 171
171:     def initialize(*rdns)
172:       @rdns = rdns.collect do |rdn|
173:         if rdn.is_a?(Array) and rdn.size == 2
174:           {rdn[0] => rdn[1]}
175:         else
176:           rdn
177:         end
178:       end
179:     end
parse(source) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 157
157:       def parse(source)
158:         Parser.new(source).parse
159:       end

Public Instance Methods

+(other) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 185
185:     def +(other)
186:       self.class.new(*(@rdns + other.rdns))
187:     end
-(other) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 189
189:     def -(other)
190:       rdns = @rdns.dup
191:       normalized_rdns = normalize(@rdns)
192:       normalize(other.rdns).reverse_each do |rdn|
193:         if rdn == normalized_rdns.pop
194:           rdns.pop
195:         else
196:           raise ArgumentError, _("%s isn't sub DN of %s") % [other, self]
197:         end
198:       end
199:       self.class.new(*rdns)
200:     end
<<(rdn) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 202
202:     def <<(rdn)
203:       @rdns << rdn
204:       self
205:     end
<=>(other) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 216
216:     def <=>(other)
217:       other = DN.parse(other) if other.is_a?(String)
218:       return nil unless other.is_a?(self.class)
219:       normalize_for_comparing(@rdns) <=>
220:         normalize_for_comparing(other.rdns)
221:     end
==(other) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 223
223:     def ==(other)
224:       case other
225:       when self.class
226:         normalize(@rdns) == normalize(other.rdns)
227:       when String
228:         parsed_other = nil
229:         begin
230:           parsed_other = self.class.parse(other)
231:         rescue DistinguishedNameInvalid
232:           return false
233:         end
234:         self == parsed_other
235:       else
236:         false
237:       end
238:     end
blank?() click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 181
181:     def blank?
182:       @rdns.blank?
183:     end
eql?(other) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 240
240:     def eql?(other)
241:       other.is_a?(self.class) and
242:         normalize(@rdns).to_s.eql?(normalize(other.rdns).to_s)
243:     end
hash() click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 245
245:     def hash
246:       normalize(@rdns).to_s.hash
247:     end
parent() click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 211
211:     def parent
212:       return nil if @rdns.size <= 1
213:       self.class.new(*@rdns[1..1])
214:     end
to_human_readable_format() click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 264
264:     def to_human_readable_format
265:       to_s.inspect
266:     end
to_s() click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 249
249:     def to_s
250:       klass = self.class
251:       @rdns.collect do |rdn|
252:         rdn.sort_by do |type, value|
253:           type.upcase
254:         end.collect do |type, value|
255:           "#{type}=#{klass.escape_value(value)}"
256:         end.join("+")
257:       end.join(",")
258:     end
to_str() click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 260
260:     def to_str # for backward compatibility
261:       to_s
262:     end
unshift(rdn) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 207
207:     def unshift(rdn)
208:       @rdns.unshift(rdn)
209:     end

Private Instance Methods

normalize(rdns) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 269
269:     def normalize(rdns)
270:       rdns.collect do |rdn|
271:         normalized_rdn = {}
272:         rdn.each do |key, value|
273:           normalized_rdn[key.upcase] = value.upcase
274:         end
275:         normalized_rdn
276:       end
277:     end
normalize_for_comparing(rdns) click to toggle source
     # File lib/active_ldap/distinguished_name.rb, line 279
279:     def normalize_for_comparing(rdns)
280:       normalize(rdns).collect do |rdn|
281:         rdn.sort_by do |key, value|
282:           key
283:         end
284:       end.collect do |key, value|
285:         [key, value]
286:       end
287:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.