redis/redis-rb — pull request #379 by joshuaflanagan (2013-10-31 22:49:21+00:00)
Title: Expose SCAN command as an Enumerator

I believe the new SCAN commands lend themselves naturally to Enumerator behavior. There are very few cases where the consuming code will care about the `cursor` value that is returned - most will just want to iterate through all of the values that get returned.

I understand this library is intended to provide a very thin wrapper over the Redis API, but this seems to be one of the few cases where adding a little language sugar would be valuable.

I named the method `scan_each` just to demonstrate it, but I think it makes sense to make this the default implementation of the `scan` method, and possibly expose the lower-level method (the existing implementation) via another name.

I only implemented the one method for now, but can implement the rest if it is agreed that this approach is valuable.