Class: Liquid::ResourceLimits

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid/resource_limits.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limits) ⇒ ResourceLimits

Returns a new instance of ResourceLimits.



6
7
8
9
10
11
# File 'lib/liquid/resource_limits.rb', line 6

def initialize(limits)
  @render_length_limit = limits[:render_length_limit]
  @render_score_limit = limits[:render_score_limit]
  @assign_score_limit = limits[:assign_score_limit]
  reset
end

Instance Attribute Details

#assign_scoreObject

Returns the value of attribute assign_score.



3
4
5
# File 'lib/liquid/resource_limits.rb', line 3

def assign_score
  @assign_score
end

#assign_score_limitObject

Returns the value of attribute assign_score_limit.



3
4
5
# File 'lib/liquid/resource_limits.rb', line 3

def assign_score_limit
  @assign_score_limit
end

#render_lengthObject

Returns the value of attribute render_length.



3
4
5
# File 'lib/liquid/resource_limits.rb', line 3

def render_length
  @render_length
end

#render_length_limitObject

Returns the value of attribute render_length_limit.



3
4
5
# File 'lib/liquid/resource_limits.rb', line 3

def render_length_limit
  @render_length_limit
end

#render_scoreObject

Returns the value of attribute render_score.



3
4
5
# File 'lib/liquid/resource_limits.rb', line 3

def render_score
  @render_score
end

#render_score_limitObject

Returns the value of attribute render_score_limit.



3
4
5
# File 'lib/liquid/resource_limits.rb', line 3

def render_score_limit
  @render_score_limit
end

Instance Method Details

#reached?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/liquid/resource_limits.rb', line 13

def reached?
  (@render_length_limit && @render_length > @render_length_limit) ||
    (@render_score_limit && @render_score > @render_score_limit) ||
    (@assign_score_limit && @assign_score > @assign_score_limit)
end

#resetObject



19
20
21
# File 'lib/liquid/resource_limits.rb', line 19

def reset
  @render_length = @render_score = @assign_score = 0
end