class ActiveLdap::Association::Proxy

def ===(other)

def ===(other)
  load_target and other === @target
end

def exists?

def exists?
  load_target
  not @target.nil?
end

def find_options(options={})

def find_options(options={})
  if @owner.connection != @owner.class.connection
    {:connection => @owner.connection}.merge(options)
  else
    options
  end
end

def foreign_class

def foreign_class
  klass = @owner.class.associated_class(@options[:association_id])
  klass = @owner.class.module_eval(klass) if klass.is_a?(String)
  klass
end

def foreign_key

def foreign_key
  @options[:foreign_key_name] || foreign_class.dn_attribute
end

def have_foreign_key?

def have_foreign_key?
  false
end

def infect_connection(target)

def infect_connection(target)
  conn = @owner.instance_variable_get("@connection")
  target.connection = conn if conn
end

def initialize(owner, options)

def initialize(owner, options)
  @owner = owner
  @options = options
  reset
  extend(options[:extend]) if options[:extend]
end

def load_target

def load_target
  if !@owner.new_entry? or have_foreign_key?
    begin
      @target = find_target unless loaded?
    rescue EntryNotFound
      reset
    end
  end
  loaded if target
  target
end

def loaded

def loaded
  @loaded = true
end

def loaded?

def loaded?
  @loaded
end

def method_missing(method, *args, &block)

def method_missing(method, *args, &block)
  load_target
  @target.send(method, *args, &block)
end

def primary_key

def primary_key
  @options[:primary_key_name] || @owner.dn_attribute
end

def reload

def reload
  reset
  load_target
end

def reset

def reset
  @target = nil
  @loaded = false
end

def respond_to?(symbol, include_priv=false)

def respond_to?(symbol, include_priv=false)
  proxy_respond_to?(symbol, include_priv) or
    (load_target && @target.respond_to?(symbol, include_priv))
end

def target

def target
  @target
end

def target=(target)

def target=(target)
  @target = target
  loaded
end