Class: ActiveLdap::Association::Proxy — activeldap - ActiveLdap

Class: ActiveLdap::Association::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_ldap/association/proxy.rb

Direct Known Subclasses

BelongsTo, Collection

Instance Method Summary (collapse)

Constructor Details

- (Proxy) initialize(owner, options)

Returns a new instance of Proxy



8
9
10
11
12
13
# 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &block) (private)



57
58
59
60
# File 'lib/active_ldap/association/proxy.rb', line 57

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

Instance Method Details

- (Object) ===(other)



20
21
22
# File 'lib/active_ldap/association/proxy.rb', line 20

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

- (Boolean) exists?

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/active_ldap/association/proxy.rb', line 51

def exists?
  load_target
  not @target.nil?
end

- (Object) loaded



38
39
40
# File 'lib/active_ldap/association/proxy.rb', line 38

def loaded
  @loaded = true
end

- (Boolean) loaded?

Returns:

  • (Boolean)


34
35
36
# File 'lib/active_ldap/association/proxy.rb', line 34

def loaded?
  @loaded
end

- (Object) proxy_respond_to?



4
# File 'lib/active_ldap/association/proxy.rb', line 4

alias_method :proxy_respond_to?, :respond_to?

- (Object) reload



29
30
31
32
# File 'lib/active_ldap/association/proxy.rb', line 29

def reload
  reset
  load_target
end

- (Object) reset



24
25
26
27
# File 'lib/active_ldap/association/proxy.rb', line 24

def reset
  @target = nil
  @loaded = false
end

- (Boolean) respond_to?(symbol, include_priv = false)

Returns:

  • (Boolean)


15
16
17
18
# 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

- (Object) target



42
43
44
# File 'lib/active_ldap/association/proxy.rb', line 42

def target
  @target
end

- (Object) target=(target)



46
47
48
49
# File 'lib/active_ldap/association/proxy.rb', line 46

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