# class ActiveLdap::Association::Proxy

### Public Class Methods

new(owner, options) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 8
    def initialize(owner, options)
      @owner = owner
      @options = options
      reset
      extend(options[:extend]) if options[:extend]
    end

### Public Instance Methods

===(other) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 20
    def ===(other)
      load_target and other === @target
    end

exists?() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 51
    def exists?
      load_target
      not @target.nil?
    end

loaded() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 38
    def loaded
      @loaded = true
    end

loaded?() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 34
    def loaded?
      @loaded
    end

proxy_respond_to?(symbol, include_priv=false)
Alias for: respond_to?
reload() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 29
    def reload
      reset
      load_target
    end

reset() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 24
    def reset
      @target = nil
      @loaded = false
    end

respond_to?(symbol, include_priv=false) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 15
    def respond_to?(symbol, include_priv=false)
      proxy_respond_to?(symbol, include_priv) or
        (load_target && @target.respond_to?(symbol, include_priv))
    end

Also aliased as: proxy_respond_to?
target() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 42
    def target
      @target
    end

target=(target) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 46
    def target=(target)
      @target = target
      loaded
    end

### Private Instance Methods

find_options(options={}) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 93
    def find_options(options={})
      if @owner.connection != @owner.class.connection
        {:connection => @owner.connection}.merge(options)
      else
        options
      end
    end

foreign_class() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 62
    def foreign_class
      klass = @owner.class.associated_class(@options[:association_id])
      klass = @owner.class.module_eval(klass) if klass.is_a?(String)
      klass
    end

foreign_key() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 76
    def foreign_key
      @options[:foreign_key_name] || foreign_class.dn_attribute
    end

have_foreign_key?() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 68
    def have_foreign_key?
      false
    end

infect_connection(target) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 101
    def infect_connection(target)
      conn = @owner.instance_variable_get("@connection")
      target.connection = conn if conn
    end

load_target() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 80
    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

method_missing(method, *args, &block) click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 57
    def method_missing(method, *args, &block)
      load_target
      @target.send(method, *args, &block)
    end

primary_key() click to toggle source

    # File lib/active_ldap/association/proxy.rb, line 72
    def primary_key
      @options[:primary_key_name] || @owner.dn_attribute
    end