summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor/lib/thor/nested_context.rb
blob: 7d60cb1c12dd5ed4065d935bd366ff3d1483723a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Bundler::Thor
  class NestedContext
    def initialize
      @depth = 0
    end

    def enter
      push

      yield
    ensure
      pop
    end

    def entered?
      @depth.positive?
    end

  private

    def push
      @depth += 1
    end

    def pop
      @depth -= 1
    end
  end
end