Class: Qa::Authorities::Local::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/qa/authorities/local/registry.rb

Defined Under Namespace

Classes: RegistryEntry

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Registry

Returns a new instance of Registry.

Yields:

  • (_self)

Yield Parameters:



4
5
6
7
# File 'lib/qa/authorities/local/registry.rb', line 4

def initialize
  @hash = {}
  yield self if block_given?
end

Class Attribute Details

.loggerObject



21
22
23
24
25
# File 'lib/qa/authorities/local/registry.rb', line 21

def self.logger
  @logger ||= begin
    ::Rails.logger if defined? Rails && Rails.respond_to?(:logger)
  end
end

Instance Method Details

#add(subauthority, class_name) ⇒ Object



31
32
33
34
# File 'lib/qa/authorities/local/registry.rb', line 31

def add(subauthority, class_name)
  Registry.logger.debug "Registering Local QA authority: #{subauthority} - #{class_name}"
  @hash[subauthority] = RegistryEntry.new(subauthority, class_name)
end

#fetch(key) ⇒ Object



17
18
19
# File 'lib/qa/authorities/local/registry.rb', line 17

def fetch(key)
  @hash.fetch(key)
end

#instance_for(key) ⇒ Object



13
14
15
# File 'lib/qa/authorities/local/registry.rb', line 13

def instance_for(key)
  fetch(key).instance
end

#keysObject



9
10
11
# File 'lib/qa/authorities/local/registry.rb', line 9

def keys
  @hash.keys
end