andreasronge/neo4j — pull request #400 by subvertallchris (2014-08-04 23:45:09+00:00)
Title: cache class names in properties

More advanced version of #391. In addition to the class method, you can use config.yml/application.rb/whatever to control it globally.

* Class method `:cache_class` called on a model will add a `_classname` (or custom, see below) property on the node (or rel, soon!) during create. This fixes the n+1 queries issue during object loading.
* `config.neo4j[:cache_class_names] = true` will enable it globally.
* `config.neo4j[:class_name_property] = :sym` to change the property name from its default of "_classname"

This is disabled by default because mocks in the persistence specs would need some modifications to support it. I think this is a really sensible default option but I didn't want mess with all those specs unless I got more OKs. If you guys agree, I can make the required changes and this can default to on in config.yml; otherwise, it can be an opt-in option and we just need documentation to explain it.