Class: ActiveRecordDoctor::Logger::Hierarchical

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_doctor/logger/hierarchical.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Hierarchical

Returns a new instance of Hierarchical.



6
7
8
9
# File 'lib/active_record_doctor/logger/hierarchical.rb', line 6

def initialize(io)
  @io = io
  @nesting = 0
end

Instance Method Details

#log(message) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/active_record_doctor/logger/hierarchical.rb', line 11

def log(message)
  @io.puts(("  " * @nesting) + message.to_s)
  return if !block_given?

  @nesting += 1
  result = yield
  @nesting -= 1
  result
end