Sha256: d32fe545d3b87bb93d0b0511d97c2a424a18034b5da5a8ab049f3edd94011138
Contents?: true
Size: 850 Bytes
Versions: 3
Compression:
Stored size: 850 Bytes
Contents
# frozen_string_literal: true module Liquid # StrainerFactory is the factory for the filters system. module StrainerFactory extend self def add_global_filter(filter) strainer_class_cache.clear GlobalCache.add_filter(filter) end def create(context, filters = []) strainer_from_cache(filters).new(context) end def global_filter_names GlobalCache.filter_method_names end GlobalCache = Class.new(StrainerTemplate) private def strainer_from_cache(filters) if filters.empty? GlobalCache else strainer_class_cache[filters] ||= begin klass = Class.new(GlobalCache) filters.each { |f| klass.add_filter(f) } klass end end end def strainer_class_cache @strainer_class_cache ||= {} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
liquid-5.5.1 | lib/liquid/strainer_factory.rb |
liquid-5.5.0 | lib/liquid/strainer_factory.rb |
liquid-5.4.0 | lib/liquid/strainer_factory.rb |