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

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

Defined Under Namespace

Classes: RegistryEntry

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Registry.

Yields:

  • (_self)

Yield Parameters:



38
39
40
41
# File 'lib/qa/authorities/local.rb', line 38

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

Class Method Details

.loggerObject



55
56
57
58
59
# File 'lib/qa/authorities/local.rb', line 55

def self.logger
  @logger ||= begin
    ::Rails.logger if defined? Rails and Rails.respond_to? :logger
  end
end

.logger=(logger) ⇒ Object



61
62
63
# File 'lib/qa/authorities/local.rb', line 61

def self.logger= logger
  @logger = logger
end

Instance Method Details

#add(subauthority, class_name) ⇒ Object



65
66
67
68
# File 'lib/qa/authorities/local.rb', line 65

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



51
52
53
# File 'lib/qa/authorities/local.rb', line 51

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

#instance_for(key) ⇒ Object



47
48
49
# File 'lib/qa/authorities/local.rb', line 47

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

#keysObject



43
44
45
# File 'lib/qa/authorities/local.rb', line 43

def keys
  @hash.keys
end