Class ActiveLdap::Association::BelongsTo
In: lib/active_ldap/association/belongs_to.rb
Parent: Proxy
Error DeleteError LdapError AdapterNotSpecified OperationNotPermitted RequiredAttributeMissed LdifInvalid AttributeAssignmentError RequiredObjectClassMissed DistinguishedNameNotSetError StrongAuthenticationRequired ConnectionError SaveError EntryNotFound AuthenticationError EntryNotSaved UnknownAttribute ConnectionNotEstablished TimeoutError ConfigurationError AdapterNotFound DistinguishedNameInvalid ObjectClassError EntryInvalid EntryAlreadyExist Base DistinguishedName Ldif Reloadable::Deprecated Reloadable::Subclasses Enumerable Collection StandardError Children HasMany HasManyWrap BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update GetText Parser GetTextSupport Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Ldap NetLdap Normalize ActiveRecord::Callbacks ActiveRecord::Validations Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/ldif.rb lib/active_ldap/distinguished_name.rb lib/active_ldap/ldap_error.rb ClassMethods Associations ClassMethods HumanReadable lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/has_many.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb HasManyUtils Association ClassMethods Tree Acts Common LDIF Delete Find Update Operations lib/active_ldap/get_text/parser.rb GetText ClassMethods Configuration Command lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb Adapter GetTextSupport Normalize ClassMethods Attributes Escape Callbacks ClassMethods ObjectClass Helper Validations ClassMethods Connection GetTextFallback Populate Salt UserPassword ActiveLdap dot/m_40_0.png

Methods

Public Instance methods

[Source]

    # 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

[Source]

    # File lib/active_ldap/association/belongs_to.rb, line 22
22:       def updated?
23:         @updated
24:       end

Private Instance methods

[Source]

    # 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

[Source]

    # File lib/active_ldap/association/belongs_to.rb, line 27
27:       def have_foreign_key?
28:         not @owner[@options[:foreign_key_name]].nil?
29:       end

[Validate]