Permalink
Browse files

Replace map+compact with select

  • Loading branch information...
1 parent 2a9a10f commit cbf924ef0854c26d0d0340d0b09a26782e0c661d John Firebaugh committed Feb 22, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 activemodel/lib/active_model/serialization.rb
View
2 activemodel/lib/active_model/serialization.rb
@@ -76,7 +76,7 @@ def serializable_hash(options = nil)
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

0 comments on commit cbf924e

Please sign in to comment.