Use invoke_drop in map filter

This commit is contained in:
Florian Weingarten
2013-07-24 18:00:16 -04:00
parent f7d1e1d0c1
commit 8204c61e31
3 changed files with 16 additions and 7 deletions
+2 -4
View File
@@ -93,10 +93,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