Fixed condition constains operator with wrong data type

"contains" operator on wrong data type should not cause NoMethodError.
This commit is contained in:
Bogdan Gusiev
2014-08-18 17:32:29 +03:00
parent c0ec0652ae
commit 4e9d414fde
3 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -15,7 +15,9 @@ module Liquid
'>'.freeze => :>,
'>='.freeze => :>=,
'<='.freeze => :<=,
'contains'.freeze => lambda { |cond, left, right| left && right ? left.include?(right) : false }
'contains'.freeze => lambda { |cond, left, right|
left && right && left.respond_to?(:include?) ? left.include?(right) : false
}
}
def self.operators