Use invoke_drop in map filter

This commit is contained in:
Florian Weingarten
2013-07-24 15:41:50 -04:00
parent fbfda1a189
commit f9027d54ab
3 changed files with 16 additions and 7 deletions
+2 -4
View File
@@ -100,10 +100,8 @@ module Liquid
# map/collect on a given property
def map(input, property)
ary = [input].flatten
if ary.first.respond_to?('[]') and !ary.first[property].nil?
ary.map {|e| e[property] }
elsif ary.first.respond_to?(property)
ary.map {|e| e.send(property) }
ary.map do |e|
e.respond_to?('[]') ? e[property] : nil
end
end