Class: ROM::LDAP::Directory Abstract
- Inherits:
-
Object
- Object
- ROM::LDAP::Directory
- Includes:
- Capabilities, Operations, Root, Tokenization, Transactions
- Defined in:
- lib/rom/ldap/directory.rb,
lib/rom/ldap/directory/env.rb,
lib/rom/ldap/directory/root.rb,
lib/rom/ldap/directory/entry.rb,
lib/rom/ldap/directory/password.rb,
lib/rom/ldap/directory/operations.rb,
lib/rom/ldap/directory/capabilities.rb,
lib/rom/ldap/directory/tokenization.rb,
lib/rom/ldap/directory/transactions.rb
Overview
Builds LDAP directory abstraction over TCP connection instance. Includes vendor specific modules once initialised.
Defined Under Namespace
Modules: Capabilities, Operations, Root, Tokenization, Transactions Classes: ENV, Entry, Password
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#attribute_by(key, value) ⇒ Hash
Query parsed attribute definition hashes by key.
-
#attribute_types ⇒ Array<Hash>
Parsed attributes.
-
#base ⇒ String
Initial search base.
-
#canonical_attributes(attrs) ⇒ Array<String>
Look up canonical name for a formatted attribute.
-
#client ⇒ Client
Encapsulates encoding and binding using socket.
-
#disconnect ⇒ TrueClass
Expected method inside gateway.
-
#initialize(uri, options) ⇒ ROM::LDAP::Directory
constructor
Load vendor specific methods into the instance as singletons.
- #inspect ⇒ String
-
#key_map ⇒ Hash
Hash of attribute names converted => original.
Methods included from Transactions
Methods included from Operations
#add, #base_total, #bind_as, #by_dn, #debug, #delete, #find, included, #modify, #query, #query_attributes
Methods included from Tokenization
Methods included from Capabilities
#bitwise?, #capabilities, #chainable?, #i18n?, #pageable?, #pruneable?, #sortable?
Methods included from Root
#contexts, #schema_attribute_types, #schema_object_classes, #sub_schema_entry, #supported_controls, #supported_extensions, #supported_features, #supported_mechanisms, #supported_versions, #type, #vendor, #vendor_name, #vendor_version
Constructor Details
#initialize(uri, options) ⇒ ROM::LDAP::Directory
Load vendor specific methods into the instance as singletons
30 31 32 33 34 35 36 |
# File 'lib/rom/ldap/directory.rb', line 30 def initialize(uri, ) @env = ENV.new(uri, ) @logger = .fetch(:logger, Logger.new($stdout)) require "rom/ldap/directory/vendors/#{type}" extend LDAP.const_get(Inflector.camelize(type)) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
22 23 24 |
# File 'lib/rom/ldap/directory.rb', line 22 def env @env end |
#logger ⇒ Object
Returns the value of attribute logger.
21 22 23 |
# File 'lib/rom/ldap/directory.rb', line 21 def logger @logger end |
Instance Method Details
#attribute_by(key, value) ⇒ Hash
Query parsed attribute definition hashes by key.
103 104 105 |
# File 'lib/rom/ldap/directory.rb', line 103 def attribute_by(key, value) attribute_types.find { |a| a[key].eql?(value) } || EMPTY_HASH end |
#attribute_types ⇒ Array<Hash>
Parsed attributes. Output influenced by LDAP.formatter. Ordered alphabetically.
75 76 77 |
# File 'lib/rom/ldap/directory.rb', line 75 def attribute_types @attribute_types ||= schema_attribute_types.map(&method(:to_attribute)).flatten.freeze end |
#base ⇒ String
Initial search base.
49 50 51 |
# File 'lib/rom/ldap/directory.rb', line 49 def base env.base end |
#canonical_attributes(attrs) ⇒ Array<String>
Look up canonical name for a formatted attribute.
87 88 89 90 91 |
# File 'lib/rom/ldap/directory.rb', line 87 def canonical_attributes(attrs) attrs.map do |formatted| attribute_by(:name, formatted).fetch(:canonical, formatted.to_s) end end |
#client ⇒ Client
Encapsulates encoding and binding using socket.
57 58 59 |
# File 'lib/rom/ldap/directory.rb', line 57 def client @client ||= Client.new(env.to_h) end |
#disconnect ⇒ TrueClass
Expected method inside gateway.
65 66 67 68 |
# File 'lib/rom/ldap/directory.rb', line 65 def disconnect client.close client.closed? end |
#inspect ⇒ String
120 121 122 |
# File 'lib/rom/ldap/directory.rb', line 120 def inspect "#<#{self.class} uri='#{env.connection}' vendor='#{vendor_name}' version='#{vendor_version}' />" end |
#key_map ⇒ Hash
Hash of attribute names converted => original
113 114 115 |
# File 'lib/rom/ldap/directory.rb', line 113 def key_map attribute_types.map { |a| a.values_at(:name, :canonical) }.sort.to_h end |