Module: TestProf::RSpecDissect::MemoizedInstrumentation

Defined in:
lib/test_prof/rspec_dissect.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#fetch_or_store(id) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/test_prof/rspec_dissect.rb', line 17

def fetch_or_store(id, *)
  res = nil
  Thread.current[:_rspec_dissect_let_depth] ||= 0
  Thread.current[:_rspec_dissect_let_depth] += 1
  begin
    res = if Thread.current[:_rspec_dissect_let_depth] == 1
      RSpecDissect.track(:let, id) { super }
    else
      super
    end
  ensure
    Thread.current[:_rspec_dissect_let_depth] -= 1
  end
  res
end