Class: Gitlab::TemplateParser::EvalState

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/template_parser/eval_state.rb

Overview

A class for tracking state when evaluating a template

Constant Summary collapse

MAX_LOOPS =
4

Instance Method Summary collapse

Constructor Details

#initializeEvalState

Returns a new instance of EvalState.



9
10
11
# File 'lib/gitlab/template_parser/eval_state.rb', line 9

def initialize
  @loops = 0
end

Instance Method Details

#enter_loopObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/template_parser/eval_state.rb', line 13

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