Module: ActiveLdap::Attributes::Normalizable

### Home Classes Methods

### In Files

- lib/active_ldap/attributes.rb

### Methods

- #normalize_attribute
- #normalize_attribute_name
- #normalize_attribute_options
- #unnormalize_attribute
- #unnormalize_attribute_options
- #unnormalize_attributes

### 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::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::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::Attributes::Normalizable

### Public Instance Methods

normalize_attribute(name, value) click to toggle source

Enforce typing: Hashes are for subtypes Arrays are for multiple entries

    # File lib/active_ldap/attributes.rb, line 67
    def normalize_attribute(name, value)
      if name.nil?
        raise RuntimeError, _('The first argument, name, must not be nil. '                                  'Please report this as a bug!')
      end

      name = normalize_attribute_name(name)
      [name, schema.attribute(name).normalize_value(value)]
    end

normalize_attribute_name(name) click to toggle source

    # File lib/active_ldap/attributes.rb, line 60
    def normalize_attribute_name(name)
      name.to_s.downcase
    end

normalize_attribute_options(attr, value) click to toggle source

normalize_attribute_options

Makes the Hashized value from the full attribute name e.g. userCertificate;binary => "some_bin"

    becomes userCertificate => {"binary" => "some_bin"}

    # File lib/active_ldap/attributes.rb, line 112
    def normalize_attribute_options(attr, value)
      return [attr, value] unless attr.match(/;/)

      ret_attr, *options = attr.split(/;/)
      [ret_attr,
       [options.reverse.inject(value) {|result, option| {option => result}}]]
    end

unnormalize_attribute(name, values, result={}) click to toggle source

    # File lib/active_ldap/attributes.rb, line 85
    def unnormalize_attribute(name, values, result={})
      if values.empty?
        result[name] = []
      else
        values.each do |value|
          if value.is_a?(Hash)
            suffix, real_value = unnormalize_attribute_options(value)
            new_name = name + suffix
            unnormalize_attribute(new_name, real_value, result)
          else
            result[name] ||= []
            if value.is_a?(DN)
              result[name] << value.to_s
            else
              result[name] << value.dup
            end
          end
        end
      end
      result
    end

unnormalize_attribute_options(value) click to toggle source

unnormalize_attribute_options

Unnormalizes all of the subtypes from a given set of nested hashes and returns the attribute suffix and the final true value

    # File lib/active_ldap/attributes.rb, line 124
    def unnormalize_attribute_options(value)
      options = ''
      ret_val = value
      if value.class == Hash
        options = ';' + value.keys[0]
        ret_val = value[value.keys[0]]
        if ret_val.class == Hash
          sub_options, ret_val = unnormalize_attribute_options(ret_val)
          options += sub_options
        end
      end
      ret_val = [ret_val] unless ret_val.class == Array
      [options, ret_val]
    end

unnormalize_attributes(attributes) click to toggle source

    # File lib/active_ldap/attributes.rb, line 77
    def unnormalize_attributes(attributes)
      result = {}
      attributes.each do |name, values|
        unnormalize_attribute(name, values, result)
      end
      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.