Module: Asgard::Base::Registry

Included in:
Asgard::Base
Defined in:
lib/asgard/base/registry.rb

Overview

Tracks every Asgard::Base subclass ever defined, and every method name's full source_location history — the data Doctor (asgard --doctor) uses to detect a silently-overridden def, same file or across files.

Instance Method Summary collapse

Instance Method Details

#_method_logObject

Every source_location a method name has ever been defined at, in definition order — so a later def silently overriding an earlier one (same name, different file) is still visible after the fact. Doctor is the consumer; asgard itself doesn't otherwise care once the last definition wins.



33
34
35
# File 'lib/asgard/base/registry.rb', line 33

def _method_log
  @_method_log ||= Hash.new { |h, k| h[k] = [] }
end

#inherited(subclass) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/asgard/base/registry.rb', line 14

def inherited(subclass)
  super
  Asgard::Base.subclasses << subclass
  subclass.instance_variable_set(:@_deps,              {})
  subclass.instance_variable_set(:@_method_log,        Hash.new { |h, k| h[k] = [] })
  subclass.instance_variable_set(:@_pending_deps,      [])
  subclass.instance_variable_set(:@_pending_single_desc,      nil)
  subclass.instance_variable_set(:@_pending_single_desc_opts, nil)
  subclass.instance_variable_set(:@_running,    Set.new)
  subclass.instance_variable_set(:@_done,       Set.new)
  subclass.instance_variable_set(:@_cond,       Hash.new { |h, k| h[k] = ConditionVariable.new })
  subclass.instance_variable_set(:@_ran_mutex,  Mutex.new)
end

#subclassesObject



10
11
12
# File 'lib/asgard/base/registry.rb', line 10

def subclasses
  @subclasses ||= []
end