Merge pull request #232 from Shopify/to_liquid_stuff

Always call 'to_liquid' on stuff in map filter and allow to_liquid to be...
This commit is contained in:
Florian Weingarten
2013-10-09 15:24:20 -04:00
committed by Arthur Neves
parent 2e71ce1efe
commit 6eb1f174de
3 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ module Liquid
# Check for method existence without invoking respond_to?, which creates symbols
def self.invokable?(method_name)
@invokable_methods ||= Set.new((public_instance_methods - Liquid::Drop.public_instance_methods).map(&:to_s))
@invokable_methods ||= Set.new(["to_liquid"] + (public_instance_methods - Liquid::Drop.public_instance_methods).map(&:to_s))
@invokable_methods.include?(method_name.to_s)
end
end
+7 -1
View File
@@ -94,7 +94,13 @@ module Liquid
def map(input, property)
ary = [input].flatten
ary.map do |e|
e.respond_to?('[]') ? e[property] : nil
if e.respond_to?(:to_liquid)
e = e.to_liquid
end
if e.respond_to?('[]')
e[property]
end
end
end