Welcome to mirror list, hosted at ThFree Co, Russian Federation.

eval_state.rb « changelog « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a0439df60cff8ac3f661fcfdb48c29c55e2805c4 (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
# frozen_string_literal: true

module Gitlab
  module Changelog
    # A class for tracking state when evaluating a template
    class EvalState
      MAX_LOOPS = 4

      def initialize
        @loops = 0
      end

      def enter_loop
        if @loops == MAX_LOOPS
          raise Error, "You can only nest up to #{MAX_LOOPS} loops"
        end

        @loops += 1
        retval = yield
        @loops -= 1

        retval
      end
    end
  end
end