andreasronge/neo4j-cypher — pull request #1 by saterus (2013-06-24 19:05:06+00:00)
Title: Enhancements to ResultWrapper

After working with the Cypher DSL for a little while I ran into a few things I thought could be improved. Here's my best shot at it.

1. The ResultWrapper is Enumerable, but wasn't chainable. In the Ruby core Enumerables, you can chain the Enumerable calls together. This makes working with them quite nice.
```ruby
[:a, :b, :c].each_with_index.map{|e, i| "#{i}. #{e}" }
# => ["0. a", "1. b", "2. c"]
```
I made a small change to make this happen with the ResultWrapper. I think it makes the ResultWrapper a little nicer to work with. This still works as expected with the read-once nature of the ResultWrapper.

2. Which brings up the read-once nature of ResultWrapper...it previously "failed" silently. This was leading me to not trust my explorations in pry. I was constantly rerunning queries while checking to see if the query returned any results. I much prefer to be notified that the results have been emptied than to have it simply return an empty array.
The change I've made throws an exception after the first consumption. I had to change a couple of other specs to actually account for this (they didn't actually take into the read-once restriction).

3. I renamed ResultWrapper#map to ResultWrapper#symbolize_row_keys. This means that we don't override #map with a different method signature (letting us directly call #map on our results!). It has a name that fits its real purpose. I also marked it private since it was only annotated before.

4. Most minor of all, this gem hadn't been updated since the Rubygems.org incident, and Bundler was complaining that the Gemfile wasn't using an https source.

I've run all the specs with these changes. I'm quite happy to work with you on any changes (stylistic or otherwise). Keep any commits you like, I'll help fix any that need it, drop any you'd prefer not to have.

I decided to go ahead with these changes in an attempt to make things even a little bit better. Open source FTW.