Class: GitHub::Ldap::ConnectionCache

Inherits:
Object
  • Object
show all
Defined in:
lib/github/ldap/connection_cache.rb

Overview

A simple cache of GitHub::Ldap objects to prevent creating multiple instances of connections that point to the same URI/host.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_connection(options = {}) ⇒ Object

Public - Create or return cached instance of GitHub::Ldap created with options, where the cache key is the value of options.

options - Initialization attributes suitable for creating a new connection with GitHub::Ldap.new(options)

Returns true or false.



15
16
17
18
# File 'lib/github/ldap/connection_cache.rb', line 15

def self.get_connection(options={})
  @cache ||= self.new
  @cache.get_connection(options)
end

Instance Method Details

#get_connection(options) ⇒ Object



20
21
22
23
# File 'lib/github/ldap/connection_cache.rb', line 20

def get_connection(options)
  @connections ||= {}
  @connections[options[:host]] ||= GitHub::Ldap.new(options)
end