### Home Classes Methods

### In Files

- lib/active_ldap/persistence.rb

### Methods

- #create
- #create_or_update
- #delete
- #destroy
- #new_entry?
- #persisted?
- #reload
- #save
- #save!
- #update

### 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::Persistence

### Public Instance Methods

create() click to toggle source

    # File lib/active_ldap/persistence.rb, line 54
    def create
      prepare_data_for_saving do |data, ldap_data|
        attributes = collect_all_attributes(data)
        add_entry(dn, attributes)
        @new_entry = false
        true
      end
    end

create_or_update() click to toggle source

    # File lib/active_ldap/persistence.rb, line 50
    def create_or_update
      new_entry? ? create : update
    end

delete(options={}) click to toggle source

    # File lib/active_ldap/persistence.rb, line 23
    def delete(options={})
      if persisted?
        default_options = {
          :connection => connection,
        }
        self.class.delete_entry(dn, default_options.merge(options))
      end
      @new_entry = true
      freeze
    end

destroy() click to toggle source

destroy

Delete this entry from LDAP

    # File lib/active_ldap/persistence.rb, line 18
    def destroy
      # TODO: support deleting relations
      delete
    end

new_entry?() click to toggle source

new_entry?

Return whether the entry is new entry in LDAP or not

    # File lib/active_ldap/persistence.rb, line 6
    def new_entry?
      @new_entry
    end

persisted?() click to toggle source

Return whether the entry is saved entry or not.

    # File lib/active_ldap/persistence.rb, line 11
    def persisted?
      not new_entry?
    end

reload() click to toggle source

    # File lib/active_ldap/persistence.rb, line 84
    def reload
      clear_association_cache
      _, attributes = search(:value => id).find do |_dn, _attributes|
        dn == _dn
      end
      if attributes.nil?
        raise EntryNotFound, _("Can't find DN '%s' to reload") % dn
      end

      @ldap_data.update(attributes)
      classes = extract_object_class!(attributes)
      self.classes = classes
      self.attributes = attributes
      @new_entry = false
      self
    end

save(*) click to toggle source

save

Save and validate this object into LDAP either adding or replacing attributes TODO: Relative DN support

    # File lib/active_ldap/persistence.rb, line 39
    def save(*)
      create_or_update
    end

save!(*) click to toggle source

    # File lib/active_ldap/persistence.rb, line 43
    def save!(*)
      unless create_or_update
        raise EntryNotSaved, _("entry %s can't be saved") % dn
      end
      true
    end

update() click to toggle source

    # File lib/active_ldap/persistence.rb, line 63
    def update
      prepare_data_for_saving do |data, ldap_data|
        new_dn_value, attributes = collect_modified_attributes(ldap_data, data)
        modify_entry(@original_dn, attributes)
        if new_dn_value
          old_dn_base = DN.parse(@original_dn).parent
          new_dn_base = dn.clone.parent
          if old_dn_base == new_dn_base
            new_superior = nil
          else
            new_superior = new_dn_base.to_s
          end
          modify_rdn_entry(@original_dn,
                           "#{dn_attribute}=#{DN.escape_value(new_dn_value)}",
                           true,
                           new_superior)
        end
        true
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.