andreasronge/neo4j — pull request #391 by subvertallchris (2014-07-24 21:37:42+00:00)
Title: support for hidden _classname property and cache_class method

This does two important things:

First, it adds support for the `_classname` property on nodes to resolve https://github.com/andreasronge/neo4j-core/issues/79. Each of those second queries pointed out in that issue is an attempt to determine the class of the node. This patch changes the behavior to look for a `_classname` property and if it finds it, it uses the value to wrap the class. If it does not find it, it performs a label lookup.

Second, it adds a `cache_class` class method for nodes. Add this to any model and `_classname` will be set automatically. Frankly, I think this should be automatic for every node but a lot of specs break when this is added in, so I had to make it an opt-in option. (Is this the first step towards a master ActiveNode class that all others inherit from, similar to `Neo4j::Rails::Model` in 2.x?)

I'm pushing this to your UUID branch because you added the behavior that undeclared properties are hidden during the node wrap. This is important because _classname should not be visible to users.

The result is that it cuts the number of queries in half for many pages. The label query/return is quick but I can't see how it wouldn't make a difference on a busy app.