Class ActiveLdap::Association::Collection
In: lib/active_ldap/association/collection.rb
Parent: Proxy
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations 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 Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb 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 Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_44_0.png

Methods

Included Modules

Enumerable

Public Instance methods

[Source]

    # File lib/active_ldap/association/collection.rb, line 18
18:       def <<(*entries)
19:         add_entries(*entries)
20:       end
concat(*entries)

Alias for #<<

[Source]

    # File lib/active_ldap/association/collection.rb, line 28
28:       def delete(*entries)
29:         entries = flatten_deeper(entries).reject do |entry|
30:           @target.delete(entry) if entry.new_entry?
31:           entry.new_entry?
32:         end
33:         return if entries.empty?
34: 
35:         delete_entries(entries)
36:         entries.each do |entry|
37:           @target.delete(entry)
38:         end
39:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 24
24:       def each(&block)
25:         to_ary.each(&block)
26:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 50
50:       def exists?
51:         load_target
52:         not @target.empty?
53:       end
push(*entries)

Alias for #<<

[Source]

    # File lib/active_ldap/association/collection.rb, line 41
41:       def replace(others)
42:         load_target
43:         deleted_entries = @target - others
44:         added_entries = others - @target
45: 
46:         delete(deleted_entries)
47:         concat(added_entries)
48:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 13
13:       def reset
14:         @target = []
15:         @loaded = false
16:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 8
 8:       def to_ary
 9:         load_target
10:         @target.to_ary
11:       end

Private Instance methods

[Source]

    # File lib/active_ldap/association/collection.rb, line 67
67:       def add_entries(*entries)
68:         result = true
69:         load_target
70: 
71:         flatten_deeper(entries).each do |entry|
72:           unless @owner.new_entry?
73:             infect_connection(entry)
74:             result &&= insert_entry(entry)
75:           end
76:           @target << entry
77:         end
78: 
79:         result && self
80:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 82
82:       def dn_values_to_string_values(values)
83:         values.collect do |value|
84:           if value.is_a?(DN)
85:             value.to_s
86:           else
87:             value
88:           end
89:         end
90:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 56
56:       def flatten_deeper(array)
57:         array.collect do |element|
58:           element.respond_to?(:flatten) ? element.flatten : element
59:         end.flatten
60:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 62
62:       def insert_entry(entry)
63:         entry[@options[:foreign_key_name]] = @owner[@options[:local_key_name]]
64:         entry.save
65:       end

[Validate]