mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Merge pull request #465 from Shopify/avoid_multi_assigns
Avoid parallel assignments
This commit is contained in:
@@ -11,7 +11,8 @@ class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
||||
private
|
||||
|
||||
def handle(type, req, res)
|
||||
@request, @response = req, res
|
||||
@request = req
|
||||
@response = res
|
||||
|
||||
@request.path_info =~ /(\w+)\z/
|
||||
@action = $1 || 'index'
|
||||
|
||||
@@ -28,7 +28,9 @@ module Liquid
|
||||
attr_accessor :left, :operator, :right
|
||||
|
||||
def initialize(left = nil, operator = nil, right = nil)
|
||||
@left, @operator, @right = left, operator, right
|
||||
@left = left
|
||||
@operator = operator
|
||||
@right = right
|
||||
@child_relation = nil
|
||||
@child_condition = nil
|
||||
end
|
||||
@@ -47,11 +49,13 @@ module Liquid
|
||||
end
|
||||
|
||||
def or(condition)
|
||||
@child_relation, @child_condition = :or, condition
|
||||
@child_relation = :or
|
||||
@child_condition = condition
|
||||
end
|
||||
|
||||
def and(condition)
|
||||
@child_relation, @child_condition = :and, condition
|
||||
@child_relation = :and
|
||||
@child_condition = condition
|
||||
end
|
||||
|
||||
def attach(attachment)
|
||||
@@ -94,7 +98,8 @@ module Liquid
|
||||
# return this as the result.
|
||||
return context[left] if op == nil
|
||||
|
||||
left, right = context[left], context[right]
|
||||
left = context[left]
|
||||
right = context[right]
|
||||
|
||||
operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}"))
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ module Liquid
|
||||
def lax_parse(markup)
|
||||
@filters = []
|
||||
if markup =~ /(#{QuotedFragment})(.*)/om
|
||||
name_markup, filter_markup = $1, $2
|
||||
name_markup = $1
|
||||
filter_markup = $2
|
||||
@name = Expression.parse(name_markup)
|
||||
if filter_markup =~ /#{FilterSeparator}\s*(.*)/om
|
||||
filters = $1.scan(FilterParser)
|
||||
|
||||
@@ -57,7 +57,8 @@ class StrainerUnitTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_strainer_uses_a_class_cache_to_avoid_method_cache_invalidation
|
||||
a, b = Module.new, Module.new
|
||||
a = Module.new
|
||||
b = Module.new
|
||||
strainer = Strainer.create(nil, [a,b])
|
||||
assert_kind_of Strainer, strainer
|
||||
assert_kind_of a, strainer
|
||||
|
||||
Reference in New Issue
Block a user