Parent

Files

Class/Module Index [+]

Quicksearch

ActiveLdap::EntryAttribute

Attributes

may[R]
must[R]
object_classes[R]
schemata[R]

Public Class Methods

new(schema, object_classes) click to toggle source
# File lib/active_ldap/entry_attribute.rb, line 8
def initialize(schema, object_classes)
  @schemata = {}
  @names = {}
  @normalized_names = {}
  @aliases = {}
  @must = []
  @may = []
  @object_classes = []
  register(schema.attribute('objectClass')) if schema
  object_classes.each do |objc|
    # get all attributes for the class
    object_class = schema.object_class(objc)
    @object_classes << object_class
    @must.concat(object_class.must)
    @may.concat(object_class.may)
  end
  @must.uniq!
  @may.uniq!
  (@must + @may).each do |attr|
    # Update attr_method with appropriate
    register(attr)
  end
end

Public Instance Methods

all_names() click to toggle source
# File lib/active_ldap/entry_attribute.rb, line 63
def all_names
  @names.keys + @aliases.keys
end
exist?(name) click to toggle source
# File lib/active_ldap/entry_attribute.rb, line 59
def exist?(name)
  not normalize(name).nil?
end
names(normalize=false) click to toggle source
# File lib/active_ldap/entry_attribute.rb, line 32
def names(normalize=false)
  names = @names.keys
  if normalize
    names.collect do |name|
      normalize(name)
    end.uniq
  else
    names
  end
end
normalize(name, allow_normalized_name=false) click to toggle source
# File lib/active_ldap/entry_attribute.rb, line 43
def normalize(name, allow_normalized_name=false)
  return name if name.nil?
  return nil if @names.empty? and @aliases.empty?
  name = name.to_s
  real_name = @names[name]
  real_name ||= @aliases[name.underscore]
  if real_name
    real_name
  elsif allow_normalized_name
    return nil if @normalized_names.empty?
    @normalized_names[normalize_attribute_name(name)]
  else
    nil
  end
end
register(attribute) click to toggle source

register

Make a method entry for every alias of a valid attribute and map it onto the first attribute passed in.

# File lib/active_ldap/entry_attribute.rb, line 71
def register(attribute)
  real_name = attribute.name
  return if @schemata.has_key?(real_name)
  @schemata[real_name] = attribute
  ([real_name] + attribute.aliases).each do |name|
    @names[name] = real_name
    @aliases[name.underscore] = real_name
    @normalized_names[normalize_attribute_name(name)] = real_name
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.