Module: Delfos::CallStack

Extended by:
CallStack
Included in:
CallStack
Defined in:
lib/delfos/call_stack.rb,
lib/delfos/call_stack/stack.rb

Defined Under Namespace

Classes: PoppingEmptyStackError, Stack

Constant Summary collapse

CALL_STACK_MUTEX =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#popObject



27
28
29
# File 'lib/delfos/call_stack.rb', line 27

def pop
  stack.pop
end

#pop_until_top!Object



31
32
33
# File 'lib/delfos/call_stack.rb', line 31

def pop_until_top!
  stack.pop_until_top!
end

#push(method_object) ⇒ Object



23
24
25
# File 'lib/delfos/call_stack.rb', line 23

def push(method_object)
  stack.push(method_object)
end

#reset!Object



11
12
13
14
15
# File 'lib/delfos/call_stack.rb', line 11

def reset!
  CALL_STACK_MUTEX.synchronize do
    Thread.current[:_delfos__call_stack] = nil
  end
end

#save!(call_sites, execution_number) ⇒ Object



35
36
37
# File 'lib/delfos/call_stack.rb', line 35

def save!(call_sites, execution_number)
  Delfos::MethodLogging.save_call_stack(call_sites, execution_number)
end

#stackObject



17
18
19
20
21
# File 'lib/delfos/call_stack.rb', line 17

def stack
  CALL_STACK_MUTEX.synchronize do
    Thread.current[:_delfos__call_stack] ||= Stack.new(on_empty: method(:save!))
  end
end