Method: Cutoff.stop

Defined in:
lib/cutoff.rb

.stop(cutoff = nil) ⇒ Cutoff?

Remove the top Cutoff from the stack

Parameters:

  • cutoff (Cutoff) (defaults to: nil)

    If given, the top instance will only be removed if it matches the given cutoff instance

Returns:

  • (Cutoff, nil)

    If a cutoff was removed it is returned



51
52
53
54
55
56
57
58
59
60
# File 'lib/cutoff.rb', line 51

def stop(cutoff = nil)
  stack = Thread.current[CURRENT_STACK_KEY]
  return unless stack

  top = stack.last
  stack.pop if cutoff.nil? || top == cutoff
  clear_all if stack.empty?

  cutoff
end