Only use MethodLiteral in condition expressions (#1300)

This commit is contained in:
Dylan Thacker-Smith
2020-09-25 11:10:33 -04:00
committed by GitHub
parent ca4b9b43af
commit a03f02789b
4 changed files with 31 additions and 22 deletions
+2 -15
View File
@@ -2,25 +2,12 @@
module Liquid
class Expression
class MethodLiteral
attr_reader :method_name, :to_s
def initialize(method_name, to_s)
@method_name = method_name
@to_s = to_s
end
def to_liquid
to_s
end
end
LITERALS = {
nil => nil, 'nil' => nil, 'null' => nil, '' => nil,
'true' => true,
'false' => false,
'blank' => MethodLiteral.new(:blank?, '').freeze,
'empty' => MethodLiteral.new(:empty?, '').freeze
'blank' => '',
'empty' => ''
}.freeze
SINGLE_QUOTED_STRING = /\A'(.*)'\z/m