| Class | ActiveLdap::Association::BelongsTo |
| In: |
lib/active_ldap/association/belongs_to.rb
|
| Parent: | Proxy |
# File lib/active_ldap/association/belongs_to.rb, line 6
6: def replace(entry)
7: if entry.nil?
8: @target = @owner[@options[:foreign_key_name]] = nil
9: else
10: @target = (Proxy === entry ? entry.target : entry)
11: infect_connection(@target)
12: unless entry.new_entry?
13: @owner[@options[:foreign_key_name]] = entry[primary_key]
14: end
15: @updated = true
16: end
17:
18: loaded
19: entry
20: end
# File lib/active_ldap/association/belongs_to.rb, line 31
31: def find_target
32: value = @owner[@options[:foreign_key_name]]
33: raise EntryNotFound if value.nil?
34: key = primary_key
35: if key == "dn"
36: result = foreign_class.find(value, find_options)
37: else
38: filter = {key => value}
39: options = find_options(:filter => filter, :limit => 1)
40: result = foreign_class.find(:all, options).first
41: end
42: raise EntryNotFound if result.nil?
43: result
44: end