andreasronge/neo4j-core — pull request #90 by subvertallchris (2014-07-17 18:06:23+00:00)
Title: switch self.response to response to fix duplicate cypher queries

I was troubleshooting some performance issues when I noticed that everything going through Core::Query was being sent to the server twice.

```ruby
#before

2.1.1 :001 > s = Show.first
#{:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json"}, :body=>"{\"query\":\"MATCH (n:`Show`) RETURN n ORDER BY ID(n) LIMIT 1\",\"params\":{}}"}
#{:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json"}, :body=>"{\"query\":\"MATCH (n:`Show`) RETURN n ORDER BY ID(n) LIMIT 1\",\"params\":{}}"}
=> #
2.1.1 :002 > s.bands.each{|b| puts b.name}
#{:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json"}, :body=>"{\"query\":\"MATCH (show38625:`Show`), (result:`Band`), show38625\\u003c-[:`Band#shows`]-(result:`Band`) WHERE ID(show38625) = 38625 RETURN result\",\"params\":{}}"}
#{:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json"}, :body=>"{\"query\":\"MATCH (show38625:`Show`), (result:`Band`), show38625\\u003c-[:`Band#shows`]-(result:`Band`) WHERE ID(show38625) = 38625 RETURN result\",\"params\":{}}"}
#Woe
#Javelina
#The Atlas Moth
#Wetnurse
```

Calls to `self.response` were actually executing the query again, so switching it to the set variable `response` just used what it already had.

```ruby
#after

2.1.1 :001 > s = Show.first
#{:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json"}, :body=>"{\"query\":\"MATCH (n:`Show`) RETURN n ORDER BY ID(n) LIMIT 1\",\"params\":{}}"}
=> #
2.1.1 :002 > s.bands.each{|b| puts b.name}
#{:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json"}, :body=>"{\"query\":\"MATCH (show38625:`Show`), (result:`Band`), show38625\\u003c-[:`Band#shows`]-(result:`Band`) WHERE ID(show38625) = 38625 RETURN result\",\"params\":{}}"}
#Woe
#Javelina
#The Atlas Moth
#Wetnurse
```

It's a pretty nice performance improvement. ;-)