Class ActiveLdap::Association::BelongsToMany
In: lib/active_ldap/association/belongs_to_many.rb
Parent: Collection
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid DistinguishedNameNotSetError EntryNotFound LdapError SaveError StrongAuthenticationRequired NotImplemented AdapterNotFound TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] Base DistinguishedName Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Normalizable Common Find LDIF Delete Update ActiveRecord::Callbacks GetText Parser Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport ActiveRecord::Validations Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/xml.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb Compatible ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command ClassMethods Normalizable Attributes Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Configuration ClassMethods ObjectClass ClassMethods Callbacks lib/active_ldap/get_text/parser.rb GetText lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/base.rb lib/active_ldap/adapter/jndi.rb Adapter Validations GetTextFallback Helper ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_46_0.png

Methods

Private Instance methods

[Source]

    # File lib/active_ldap/association/belongs_to_many.rb, line 25
25:       def delete_entries(entries)
26:           _foreign_class = foreign_class
27:         entries.each do |entry|
28:           entry = _foreign_class.find(entry) unless entry.is_a?(_foreign_class)
29:           old_value = entry[@options[:many], true]
30:           primary_key_name = @options[:primary_key_name]
31:           if primary_key_name == "dn"
32:             old_value = dn_values_to_string_values(old_value)
33:           end
34:           current_value = @owner[primary_key_name, true]
35:           current_value = dn_values_to_string_values(current_value)
36:           new_value = old_value - current_value
37:           new_value = new_value.uniq.sort
38:           if old_value != new_value
39:             entry[@options[:many]] = new_value
40:             entry.save
41:           end
42:         end
43:       end

[Source]

    # File lib/active_ldap/association/belongs_to_many.rb, line 45
45:       def find_target
46:         values = @owner[@options[:primary_key_name], true].compact
47:         return [] if values.empty?
48: 
49:         key = @options[:many]
50:         components = values.collect do |value|
51:           [key, value]
52:         end
53:         options = find_options(:filter => [:or, *components])
54:         foreign_class.find(:all, options)
55:       end

[Source]

    # File lib/active_ldap/association/belongs_to_many.rb, line 7
 7:       def insert_entry(entry)
 8:         _foreign_class = foreign_class
 9:         entry = _foreign_class.find(entry) unless entry.is_a?(_foreign_class)
10:         old_value = entry[@options[:many], true]
11:         primary_key_name = @options[:primary_key_name]
12:         if primary_key_name == "dn"
13:           old_value = dn_values_to_string_values(old_value)
14:         end
15:         current_value = @owner[primary_key_name, true]
16:         current_value = dn_values_to_string_values(current_value)
17:         new_value = old_value + current_value
18:         new_value = new_value.uniq.sort
19:         if old_value != new_value
20:           entry[@options[:many]] = new_value
21:           entry.save
22:         end
23:       end

[Validate]