Labels¶
Provides a mapping between neo4j labels and Ruby classes
Constants¶
- WRAPPED_CLASSES
- MODELS_FOR_LABELS_CACHE
- MODELS_TO_RELOAD
Methods¶
._wrapped_classes
def self._wrapped_classes Neo4j::ActiveNode::Labels::WRAPPED_CLASSES end
- #add_label
adds one or more labels
def add_label(*label) @_persisted_obj.add_label(*label) end
.add_wrapped_class
def self.add_wrapped_class(model) _wrapped_classes << model end
.clear_model_for_label_cache
def self.clear_model_for_label_cache MODELS_FOR_LABELS_CACHE.clear end
.clear_wrapped_models
def self.clear_wrapped_models WRAPPED_CLASSES.clear end
#labels
def labels @_persisted_obj.labels end
.model_cache
def self.model_cache(labels) models = WRAPPED_CLASSES.select do |model| (model.mapped_label_names - labels).size == 0 end MODELS_FOR_LABELS_CACHE[labels] = models.max do |model| (model.mapped_label_names & labels).size end end
.model_for_labels
def self.model_for_labels(labels) MODELS_FOR_LABELS_CACHE[labels] || model_cache(labels) end
- #remove_label
Removes one or more labels Be careful, don’t remove the label representing the Ruby class.
def remove_label(*label) @_persisted_obj.remove_label(*label) end