1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Replace map+compact with select

This commit is contained in:
John Firebaugh 2011-02-21 16:30:33 -08:00
parent 2a9a10f5e3
commit cbf924ef08

View file

@ -76,7 +76,7 @@ module ActiveModel
attribute_names -= Array.wrap(except).map(&:to_s)
end
method_names = Array.wrap(options[:methods]).map { |n| n if respond_to?(n.to_s) }.compact
method_names = Array.wrap(options[:methods]).select { |n| respond_to?(n) }
Hash[(attribute_names + method_names).map { |n| [n, send(n)] }]
end
end