rails-api/active_model_serializers — pull request #210 by tpitale (2013-02-17 21:48:27+00:00)
Title: Reduce double map to once; Fixes datamapper eager loading.

The use of #map on the original object array here: https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/array_serializer.rb#L23 causes the serializable_array to be just an array, and no longer a DataMapper::Collection. This breaks eager loading of associations when on line 50 we call #map on the serializable_array here: https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/array_serializer.rb#L50 and call serializable_hash on each entry in the array.

This second map doesn't really need to happen separately. The two maps can be combined. Ostensibly, this improves performance for large arrays being serialized, to not require looping over the collection twice.