mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Add a class cache to avoid runtime extend calls
* Strainer has a class cache that creates Strainer subclasses for each filter set that is used on .create calls. * Context now creates a list of filters and passes this to Strainer.create to utilize the class cache in almost all use cases. * If add_filter was called after a render, then the method cache may still be invalidated. Conflicts: lib/liquid/strainer.rb
This commit is contained in:
@@ -49,4 +49,15 @@ class StrainerTest < Test::Unit::TestCase
|
||||
assert_equal "has_method?", strainer.invoke("invoke", "has_method?", "invoke")
|
||||
end
|
||||
|
||||
def test_strainer_uses_a_class_cache_to_avoid_method_cache_invalidation
|
||||
a, b = Module.new, Module.new
|
||||
strainer = Strainer.create(nil, [a,b])
|
||||
assert_kind_of Strainer, strainer
|
||||
assert_kind_of a, strainer
|
||||
assert_kind_of b, strainer
|
||||
Strainer.class_variable_get(:@@filters).values.each do |m|
|
||||
assert_kind_of m, strainer
|
||||
end
|
||||
end
|
||||
|
||||
end # StrainerTest
|
||||
|
||||
Reference in New Issue
Block a user