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: values = @owner[@options[:foreign_key_name], true].compact 31: return [] if values.empty? 32: 33: key = @options[:many] 34: components = values.collect do |value| 35: [key, value] 36: end 37: options = find_options(:filter => [:or, *components]) 38: foreign_class.find(:all, options) 39: 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