### Home Classes Methods

### In Files

- lib/active_ldap/association/collection.rb

### Parent

ActiveLdap::Association::Proxy

### Methods

- #<<
- #add_entries
- #concat
- #delete
- #dn_values_to_string_values
- #each
- #exists?
- #flatten_deeper
- #insert_entry
- #push
- #replace
- #reset
- #to_ary

### Included Modules

- Enumerable

### Files

- USAGE

### Class/Module Index

Quicksearch

- ActiveLdap
- ActiveLdap::ActionController
- ActiveLdap::ActionController::LdapBenchmarking
- ActiveLdap::Acts
- ActiveLdap::Acts::Tree
- ActiveLdap::Acts::Tree::ClassMethods
- ActiveLdap::Adapter
- ActiveLdap::Adapter::Base
- ActiveLdap::Adapter::Jndi
- ActiveLdap::Adapter::JndiConnection
- ActiveLdap::Adapter::JndiConnection::ModifyRecord
- ActiveLdap::Adapter::JndiConnection::Scope
- ActiveLdap::Adapter::Ldap
- ActiveLdap::Adapter::Ldap::Method
- ActiveLdap::Adapter::Ldap::Method::Base
- ActiveLdap::Adapter::Ldap::Method::Plain
- ActiveLdap::Adapter::Ldap::Method::SSL
- ActiveLdap::Adapter::Ldap::Method::TLS
- ActiveLdap::Adapter::NetLdap
- ActiveLdap::Association
- ActiveLdap::Association::BelongsTo
- ActiveLdap::Association::BelongsToMany
- ActiveLdap::Association::Children
- ActiveLdap::Association::Collection
- ActiveLdap::Association::HasMany
- ActiveLdap::Association::HasManyUtils
- ActiveLdap::Association::HasManyWrap
- ActiveLdap::Association::Proxy
- ActiveLdap::Associations
- ActiveLdap::Associations::ClassMethods
- ActiveLdap::AttributeMethods
- ActiveLdap::AttributeMethods::BeforeTypeCast
- ActiveLdap::AttributeMethods::Dirty
- ActiveLdap::AttributeMethods::Query
- ActiveLdap::AttributeMethods::Read
- ActiveLdap::AttributeMethods::Write
- ActiveLdap::Attributes
- ActiveLdap::Attributes::ClassMethods
- ActiveLdap::Attributes::Normalizable
- ActiveLdap::Callbacks
- ActiveLdap::Callbacks::ClassMethods
- ActiveLdap::Command
- ActiveLdap::Compatible
- ActiveLdap::Configuration
- ActiveLdap::Configuration::ClassMethods
- ActiveLdap::Connection
- ActiveLdap::Connection::ClassMethods
- ActiveLdap::DN
- ActiveLdap::DistinguishedName
- ActiveLdap::DistinguishedName::Parser
- ActiveLdap::Entry
- ActiveLdap::EntryAttribute
- ActiveLdap::Escape
- ActiveLdap::Generators
- ActiveLdap::Generators::ModelGenerator
- ActiveLdap::Generators::ScaffoldGenerator
- ActiveLdap::GetText
- ActiveLdap::GetText::Parser
- ActiveLdap::GetTextSupport
- ActiveLdap::Helper
- ActiveLdap::HumanReadable
- ActiveLdap::HumanReadable::ClassMethods
- ActiveLdap::LDIF
- ActiveLdap::LdapError
- ActiveLdap::Ldif
- ActiveLdap::Ldif::AddRecord
- ActiveLdap::Ldif::Attribute
- ActiveLdap::Ldif::Attributes
- ActiveLdap::Ldif::ChangeRecord
- ActiveLdap::Ldif::ChangeRecord::Control
- ActiveLdap::Ldif::ContentRecord
- ActiveLdap::Ldif::DeleteRecord
- ActiveLdap::Ldif::ModifyDNRecord
- ActiveLdap::Ldif::ModifyNameRecord
- ActiveLdap::Ldif::ModifyRDNRecord
- ActiveLdap::Ldif::ModifyRecord
- ActiveLdap::Ldif::ModifyRecord::AddOperation
- ActiveLdap::Ldif::ModifyRecord::DeleteOperation
- ActiveLdap::Ldif::ModifyRecord::Operation
- ActiveLdap::Ldif::ModifyRecord::ReplaceOperation
- ActiveLdap::Ldif::Parser
- ActiveLdap::Ldif::Record
- ActiveLdap::Ldif::Scanner
- ActiveLdap::LogSubscriber
- ActiveLdap::ObjectClass
- ActiveLdap::ObjectClass::ClassMethods
- ActiveLdap::Operations
- ActiveLdap::Operations::ClassOnlyDelete
- ActiveLdap::Operations::ClassOnlyUpdate
- ActiveLdap::Operations::Common
- ActiveLdap::Operations::Delete
- ActiveLdap::Operations::Find
- ActiveLdap::Operations::LDIF
- ActiveLdap::Operations::LDIF::AddRecordLoadable
- ActiveLdap::Operations::LDIF::ContentRecordLoadable
- ActiveLdap::Operations::LDIF::DeleteRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyNameRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::AddOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::DeleteOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::ReplaceOperationModifiable
- ActiveLdap::Operations::Update
- ActiveLdap::Persistence
- ActiveLdap::Populate
- ActiveLdap::Railtie
- ActiveLdap::Railties
- ActiveLdap::Railties::ControllerRuntime
- ActiveLdap::Railties::ControllerRuntime::ClassMethods
- ActiveLdap::Schema
- ActiveLdap::Schema::Attribute
- ActiveLdap::Schema::Entry
- ActiveLdap::Schema::ObjectClass
- ActiveLdap::Schema::Syntax
- ActiveLdap::Schema::Syntaxes
- ActiveLdap::Schema::Syntaxes::Base
- ActiveLdap::Schema::Syntaxes::BitString
- ActiveLdap::Schema::Syntaxes::Boolean
- ActiveLdap::Schema::Syntaxes::CountryString
- ActiveLdap::Schema::Syntaxes::DirectoryString
- ActiveLdap::Schema::Syntaxes::DistinguishedName
- ActiveLdap::Schema::Syntaxes::GeneralizedTime
- ActiveLdap::Schema::Syntaxes::Integer
- ActiveLdap::Schema::Syntaxes::JPEG
- ActiveLdap::Schema::Syntaxes::NameAndOptionalUID
- ActiveLdap::Schema::Syntaxes::NumericString
- ActiveLdap::Schema::Syntaxes::OID
- ActiveLdap::Schema::Syntaxes::ObjectSecurityDescriptor
- ActiveLdap::Schema::Syntaxes::OctetString
- ActiveLdap::Schema::Syntaxes::OtherMailbox
- ActiveLdap::Schema::Syntaxes::PostalAddress
- ActiveLdap::Schema::Syntaxes::PrintableString
- ActiveLdap::Schema::Syntaxes::TelephoneNumber
- ActiveLdap::UserPassword
- ActiveLdap::UserPassword::Salt
- ActiveLdap::Validations
- ActiveLdap::XML
- ActiveLdap::Xml
- ActiveLdap::Xml::Serializer
- LDAP
- LDAP::Conn
- LDAP::Mod
- Net
- Net::LDAP
- Net::LDAP::Entry
- ActionView
- ActionView::Base
- URI
- URI::LDAPS
- Object
- Timeout

No matching classes.

# ActiveLdap::Association::Collection

### Public Instance Methods

<<(*entries) click to toggle source

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

Also aliased as: push, concat
concat(*entries) click to toggle source
Alias for: <<
delete(*entries) click to toggle source

    # File lib/active_ldap/association/collection.rb, line 28
    def delete(*entries)
      entries = flatten_deeper(entries).reject do |entry|
        @target.delete(entry) if entry.new_entry?
        entry.new_entry?
      end
      return if entries.empty?

      delete_entries(entries)
      entries.each do |entry|
        @target.delete(entry)
      end
    end

each(&block) click to toggle source

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

exists?() click to toggle source

    # File lib/active_ldap/association/collection.rb, line 62
    def exists?
      load_target
      not @target.empty?
    end

push(*entries) click to toggle source
Alias for: <<
replace(others) click to toggle source

    # File lib/active_ldap/association/collection.rb, line 41
    def replace(others)
      load_target

      entry = @target.first
      if entry.nil?
        deleted_entries = []
        added_entries = others
      else
        base_class = entry.class
        others = others.collect do |other|
          other = base_class.find(other) unless other.is_a?(base_class)
          other
        end
        deleted_entries = @target - others
        added_entries = others - @target
      end

      delete(deleted_entries)
      concat(added_entries)
    end

reset() click to toggle source

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

to_ary() click to toggle source

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

### Private Instance Methods

add_entries(*entries) click to toggle source

    # File lib/active_ldap/association/collection.rb, line 79
    def add_entries(*entries)
      result = true
      load_target

      flatten_deeper(entries).each do |entry|
        unless @owner.new_entry?
          infect_connection(entry)
          result &&= insert_entry(entry)
        end
        @target << entry
      end

      result && self
    end

dn_values_to_string_values(values) click to toggle source

    # File lib/active_ldap/association/collection.rb, line 94
    def dn_values_to_string_values(values)
      values.collect do |value|
        if value.is_a?(DN)
          value.to_s
        else
          value
        end
      end
    end

flatten_deeper(array) click to toggle source

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

insert_entry(entry) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.