Class: ROM::LDAP::Gateway Abstract
- Inherits:
-
Gateway
- Object
- Gateway
- ROM::LDAP::Gateway
- Defined in:
- lib/rom/ldap/gateway.rb
Overview
Responsible for initialising connection, binding to server. Wrapping the connection in the directory and then dataset abstractions, and passing them to the relations.
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#[](filter) ⇒ Array<Directory::Entry>
(also: #call)
Used by attribute_inferrer to query attributes.
-
#attribute_types ⇒ Array<String>
Directory attributes identifiers and descriptions.
-
#dataset(name) ⇒ Dataset
An enumerable object for chainable queries.
-
#dataset?(name) ⇒ Boolean
Check for presence of entries under new filter.
-
#directory_type ⇒ Symbol
Underlying directory type.
-
#disconnect ⇒ ?
Disconnect from the server.
-
#initialize(uri, options) ⇒ LDAP::Gateway
constructor
Initialize an LDAP gateway.
- #use_logger(logger) ⇒ Object
Constructor Details
#initialize(uri, options) ⇒ LDAP::Gateway
Initialize an LDAP gateway
Gateways are typically initialized via ROM::Configuration object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rom/ldap/gateway.rb', line 51 def initialize(uri = nil, **) @directory = Directory.new(uri, ) @logger = .fetch(:logger) { ::Logger.new(STDOUT) } .fetch(:extensions, EMPTY_ARRAY).each do |ext| next unless LDAP.available_extension?(ext) LDAP.load_extensions(ext) end super() end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
21 22 23 |
# File 'lib/rom/ldap/gateway.rb', line 21 def directory @directory end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
25 26 27 |
# File 'lib/rom/ldap/gateway.rb', line 25 def logger @logger end |
Instance Method Details
#[](filter) ⇒ Array<Directory::Entry> Also known as: call
Used by attribute_inferrer to query attributes.
72 73 74 |
# File 'lib/rom/ldap/gateway.rb', line 72 def [](filter) directory.query_attributes(filter) end |
#attribute_types ⇒ Array<String>
Directory attributes identifiers and descriptions.
86 87 88 |
# File 'lib/rom/ldap/gateway.rb', line 86 def attribute_types directory.attribute_types end |
#dataset(name) ⇒ Dataset
An enumerable object for chainable queries.
111 112 113 |
# File 'lib/rom/ldap/gateway.rb', line 111 def dataset(name) Dataset.new(name: name, directory: directory) end |
#dataset?(name) ⇒ Boolean
Check for presence of entries under new filter.
98 99 100 |
# File 'lib/rom/ldap/gateway.rb', line 98 def dataset?(name) dataset(name).any? end |
#directory_type ⇒ Symbol
Underlying directory type
129 130 131 |
# File 'lib/rom/ldap/gateway.rb', line 129 def directory_type directory.type end |
#disconnect ⇒ ?
Disconnect from the server.
139 140 141 |
# File 'lib/rom/ldap/gateway.rb', line 139 def disconnect directory.disconnect end |
#use_logger(logger) ⇒ Object
119 120 121 |
# File 'lib/rom/ldap/gateway.rb', line 119 def use_logger(logger) directory.logger = @logger = logger end |