Sha256: f49cc68c0230fc17f3a876a5840fdf8d955e73d3f752b884d04ec2d8a46d0116

Contents?: true

Size: 732 Bytes

Versions: 4

Compression:

Stored size: 732 Bytes

Contents

module Liquid
  class ResourceLimits
    attr_accessor :render_length, :render_score, :assign_score,
                  :render_length_limit, :render_score_limit, :assign_score_limit

    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

    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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotivecms-liquid-4.0.0 lib/liquid/resource_limits.rb
locomotivecms-liquid-4.0.0.alpha2 lib/liquid/resource_limits.rb
locomotivecms-liquid-4.0.0.alpha1 lib/liquid/resource_limits.rb
locomotivecms-liquid-4.0.0.alpha lib/liquid/resource_limits.rb