Method: BinData.trace_reading

Defined in:
lib/bindata/trace.rb

.trace_reading(io = STDERR) ⇒ Object

Turn on trace information when reading a BinData object. If block is given then the tracing only occurs for that block. This is useful for debugging a BinData declaration.



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

def trace_reading(io = STDERR)
  @tracer = Tracer.new(io)
  [BasePrimitive, Choice].each(&:turn_on_tracing)

  if block_given?
    begin
      yield
    ensure
      [BasePrimitive, Choice].each(&:turn_off_tracing)
      @tracer = nil
    end
  end
end