Class ActiveLdap::Association::Collection
In: lib/active_ldap/association/collection.rb
Parent: Proxy
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

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 62
62:       def exists?
63:         load_target
64:         not @target.empty?
65:       end
push(*entries)

Alias for #<<

[Source]

    # File lib/active_ldap/association/collection.rb, line 41
41:       def replace(others)
42:         load_target
43: 
44:         entry = @target.first
45:         if entry.nil?
46:           deleted_entries = []
47:           added_entries = others
48:         else
49:           base_class = entry.class
50:           others = others.collect do |other|
51:             other = base_class.find(other) unless other.is_a?(base_class)
52:             other
53:           end
54:           deleted_entries = @target - others
55:           added_entries = others - @target
56:         end
57: 
58:         delete(deleted_entries)
59:         concat(added_entries)
60:       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 79
79:       def add_entries(*entries)
80:         result = true
81:         load_target
82: 
83:         flatten_deeper(entries).each do |entry|
84:           unless @owner.new_entry?
85:             infect_connection(entry)
86:             result &&= insert_entry(entry)
87:           end
88:           @target << entry
89:         end
90: 
91:         result && self
92:       end

[Source]

     # File lib/active_ldap/association/collection.rb, line 94
 94:       def dn_values_to_string_values(values)
 95:         values.collect do |value|
 96:           if value.is_a?(DN)
 97:             value.to_s
 98:           else
 99:             value
100:           end
101:         end
102:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 68
68:       def flatten_deeper(array)
69:         array.collect do |element|
70:           element.respond_to?(:flatten) ? element.flatten : element
71:         end.flatten
72:       end

[Source]

    # File lib/active_ldap/association/collection.rb, line 74
74:       def insert_entry(entry)
75:         entry[@options[:foreign_key_name]] = @owner[@options[:local_key_name]]
76:         entry.save
77:       end

[Validate]