class ROM::LDAP::Gateway

@abstract

Responsible for initialising connection, binding to server.
Wrapping the connection in the directory and then dataset abstractions,
and passing them to the relations.

Attributes

directory[R]

@!attribute [r] directory

@return [String]
logger[R]

@!attribute [r] logger

@return [Object] configured gateway logger

Public Class Methods

new(uri = nil, **options) click to toggle source

Initialize an LDAP gateway

Gateways are typically initialized via ROM::Configuration object

@overload initialize(uri, options)

Connects to a directory via options

@example
  ROM.container(:ldap, uri, {})

@param uri [String] 'ldap://127.0.0.1:389' or nil

@option options :username [String] BINDDN Directory admin username.

@option options :password [String] BINDDN Directory admin password.

@option options :base [String] BASE Directory search base.

@option options :timeout [Integer] Connection timeout in seconds.

@option options :logger [Object] Defaults to $stdout

@return [LDAP::Gateway]

Calls superclass method
# File lib/rom/ldap/gateway.rb, line 51
def initialize(uri = nil, **options)
  @directory = Directory.new(uri, options)
  @logger = options.fetch(:logger) { ::Logger.new(STDOUT) }

  options.fetch(:extensions, EMPTY_ARRAY).each do |ext|
    next unless LDAP.available_extension?(ext)

    LDAP.load_extensions(ext)
  end

  super()
end

Public Instance Methods

[](filter) click to toggle source

Used by attribute_inferrer to query attributes.

@param filter [String]

@return [Array<Directory::Entry>]

@api public

# File lib/rom/ldap/gateway.rb, line 72
def [](filter)
  directory.query_attributes(filter)
end
Also aliased as: call
attribute_types() click to toggle source

Directory attributes identifiers and descriptions.

@see Schema::Inferrer @see Schema::TypeBuilder

@return [Array<String>]

@api public

# File lib/rom/ldap/gateway.rb, line 86
def attribute_types
  directory.attribute_types
end
call(filter)
Alias for: []
dataset(name) click to toggle source

An enumerable object for chainable queries.

@param name [String] An ldap compatible filter string.

Used as the param to schema block in relation classes.

@return [Dataset] Scoped by name filter.

@api public

# File lib/rom/ldap/gateway.rb, line 111
def dataset(name)
  Dataset.new(name: name, directory: directory)
end
dataset?(name) click to toggle source

Check for presence of entries under new filter.

@param name [String] An ldap compatible filter string.

@return [Boolean]

@api public

# File lib/rom/ldap/gateway.rb, line 98
def dataset?(name)
  dataset(name).any?
end
directory_type() click to toggle source

Underlying directory type

@return [Symbol]

@api public

# File lib/rom/ldap/gateway.rb, line 129
def directory_type
  directory.type
end
disconnect() click to toggle source

Disconnect from the server.

@return [?]

@api public

# File lib/rom/ldap/gateway.rb, line 139
def disconnect
  directory.disconnect
end
use_logger(logger) click to toggle source

@param logger [Logger]

@api public

# File lib/rom/ldap/gateway.rb, line 119
def use_logger(logger)
  directory.logger = @logger = logger
end