| Class | ActiveLdap::Association::BelongsToMany |
| In: |
lib/active_ldap/association/belongs_to_many.rb
|
| Parent: | Collection |
# File lib/active_ldap/association/belongs_to_many.rb, line 17
17: def delete_entries(entries)
18: entries.each do |entry|
19: old_value = entry[@options[:many], true]
20: new_value = old_value - @owner[@options[:foreign_key_name], true]
21: new_value = new_value.uniq.sort
22: if old_value != new_value
23: entry[@options[:many]] = new_value
24: entry.save
25: end
26: end
27: end
# File lib/active_ldap/association/belongs_to_many.rb, line 29
29: def find_target
30: key = @options[:many]
31: values = @owner[@options[:foreign_key_name], true].compact
32: components = values.collect do |value|
33: [key, value]
34: end
35: foreign_class.find(:all, :filter => [:or, *components])
36: end
# File lib/active_ldap/association/belongs_to_many.rb, line 7
7: def insert_entry(entry)
8: old_value = entry[@options[:many], true]
9: new_value = old_value + @owner[@options[:foreign_key_name], true]
10: new_value = new_value.uniq.sort
11: if old_value != new_value
12: entry[@options[:many]] = new_value
13: entry.save
14: end
15: end