Module: TestProf::RSpecDissect::MemoizedInstrumentation

Defined in:
lib/test_prof/rspec_dissect.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#fetch_or_storeObject



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(*)
  res = nil
  Thread.current[:_rspec_dissect_memo_depth] ||= 0
  Thread.current[:_rspec_dissect_memo_depth] += 1
  begin
    res = if Thread.current[:_rspec_dissect_memo_depth] == 1
            RSpecDissect.track(:memo) { super }
          else
            super
          end
  ensure
    Thread.current[:_rspec_dissect_memo_depth] -= 1
  end
  res
end