Module: Log::Registry

Included in:
Log
Defined in:
lib/log/registry.rb

Instance Method Summary collapse

Instance Method Details

#get(subject) ⇒ Object



3
4
5
# File 'lib/log/registry.rb', line 3

def get(subject)
  register(subject)
end

#register(subject) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/log/registry.rb', line 7

def register(subject)
  subject_name = subject_name(subject)

  instance = registry[subject_name]

  if instance.nil?
    instance = build(subject)
    registry[subject_name] = instance
  end

  instance
end

#registryObject



20
21
22
# File 'lib/log/registry.rb', line 20

def registry
  @registry ||= {}
end