rails-api/active_model_serializers — pull request #476 by sherwinyu (2013-12-26 23:07:50+00:00)
Title: Update README documentation on Serializer#filter

Documentation fix clarifying that `#filter` needs to return an array. Previously it said that "And it's also safe to mutate keys argument by doing keys.delete(:author) in case you want to avoid creating two extra arrays." -- I had taken this to mean that I could just modify the original `keys` argument and the return value of ```filters``` would be discarded, which is wrong. I added clarification that if you do modify the original array, you have to return it!

This lead to a tricky bug for me, where I wanted to filter out keys that had undefined values:

```
def filter(keys)
keys.reject!{ |key| object[key].nil?}
end
```

I was using the in-place ```Array#reject!``` because I thought the original array argument would be used. This was tricky because while `reject!` normally returns the array, when nothing was rejected, it returns `nil`, causing this to to fail.