Use invoke_drop in map filter

This commit is contained in:
Florian Weingarten
2013-10-09 16:32:38 -04:00
committed by Arthur Neves
parent 5c5e7de31e
commit 988a1694fd
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