# class ActiveLdap::Configuration::ClassMethods::URIConfigurationMerger

### Public Class Methods

new(uri) click to toggle source

    # File lib/active_ldap/configuration.rb, line 146
    def initialize(uri)
      @uri = uri
    end

### Public Instance Methods

merge(configuration) click to toggle source

    # File lib/active_ldap/configuration.rb, line 150
    def merge(configuration)
      uri_configuration = {:port => @uri.port}
      uri_configuration[:host] = @uri.host if @uri.host
      uri_configuration[:base] = @uri.dn if @uri.dn
      extensions = parse_extensions
      bindname_extension = extensions["bindname"]
      if bindname_extension
        uri_configuration[:bind_dn] = bindname_extension[:value]
        uri_configuration[:allow_anonymous] = !bindname_extension[:critical]
      end
      uri_configuration[:scope] = @uri.scope if @uri.scope
      uri_configuration[:method] = :ssl if @uri.is_a?(URI::LDAPS)
      uri_configuration.merge(configuration)
    end

### Private Instance Methods

parse_extensions() click to toggle source

    # File lib/active_ldap/configuration.rb, line 166
    def parse_extensions
      extensions = {}
      (@uri.extensions || "").split(",").collect do |extension|
        name, value = extension.split("=", 2)
        case name
        when /\A!/
          critical = true
          name = $POSTMATCH
        else
          critical = false
        end
        extensions[name] = {
          :critical => critical,
          :value => CGI.unescape(value || ""),
        }
      end
      extensions
    end