| 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: unless entry.new_entry?
12: @owner[@options[:foreign_key_name]] = entry[primary_key]
13: end
14: @updated = true
15: end
16:
17: loaded
18: entry
19: end
# File lib/active_ldap/association/belongs_to.rb, line 30
30: def find_target
31: value = @owner[@options[:foreign_key_name]]
32: raise EntryNotFound if value.nil?
33: filter = {primary_key => value}
34: result = foreign_class.find(:all, :filter => filter, :limit => 1)
35: raise EntryNotFound if result.empty?
36: result.first
37: end