Module: Log::Registry

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

Instance Method Summary collapse

Instance Method Details

#get(subject) ⇒ Object



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

def get(subject)
  register(subject)
end

#register(subject) ⇒ Object



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

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



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

def registry
  @registry ||= {}
end