Sha256: b461fe174cbd8b52401c8bd8f885c80af9b0260d09478d4bb3a0c9187fff80d0

Contents?: true

Size: 861 Bytes

Versions: 2

Compression:

Stored size: 861 Bytes

Contents

module ActiveLdap
  module Adaptor
    class Base
      def initialize(config={})
        @connection = nil
        @config = config.dup
        @logger = @config.delete(:logger)
        %w(host port method timeout retry_on_timeout
           retry_limit retry_wait bind_dn password
           password_block try_sasl allow_anonymous
           store_password).each do |name|
          instance_variable_set("@#{name}", config[name.to_sym])
        end
      end

      private
      def with_timeout(try_reconnect=true, &block)
        begin
          Timeout.alarm(@timeout, &block)
        rescue Timeout::Error => e
          @logger.error {'Requested action timed out.'}
          retry if try_reconnect and @retry_on_timeout and reconnect
          @logger.error {e.message}
          raise TimeoutError, e.message
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-activeldap-0.8.0 lib/active_ldap/adaptor/base.rb
ruby-activeldap-0.8.1 lib/active_ldap/adaptor/base.rb