Class: Sirius::KOSapiClientRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/sirius/kosapi_client_registry.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKOSapiClientRegistry

Returns a new instance of KOSapiClientRegistry.


4
5
6
7
# File 'lib/sirius/kosapi_client_registry.rb', line 4

def initialize
  @registry = {}
  @default_client = nil
end

Class Method Details

.instanceObject


18
19
20
# File 'lib/sirius/kosapi_client_registry.rb', line 18

def self.instance
  @instance ||= new
end

Instance Method Details

#client_for_faculty(faculty) ⇒ Object


9
10
11
# File 'lib/sirius/kosapi_client_registry.rb', line 9

def client_for_faculty(faculty)
  @registry[faculty] || @default_client
end

#register_client(client, faculty, default: false) ⇒ Object


13
14
15
16
# File 'lib/sirius/kosapi_client_registry.rb', line 13

def register_client(client, faculty, default: false)
  @registry[faculty] = client
  @default_client = client if default
end