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
@!attribute [r] directory
@return [String]
@!attribute [r] logger
@return [Object] configured gateway logger
Public Class Methods
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]
# 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
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
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
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
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
Underlying directory type
@return [Symbol]
@api public
# File lib/rom/ldap/gateway.rb, line 129 def directory_type directory.type end
Disconnect from the server.
@return [?]
@api public
# File lib/rom/ldap/gateway.rb, line 139 def disconnect directory.disconnect end
@param logger [Logger]
@api public
# File lib/rom/ldap/gateway.rb, line 119 def use_logger(logger) directory.logger = @logger = logger end