Provides a mapping between neo4j labels and Ruby classes
Labels/InvalidQueryError
Labels/RecordNotFound
Labels/ClassMethods
- WRAPPED_CLASSES
- MODELS_FOR_LABELS_CACHE
._wrapped_classes
ruby
- def self._wrapped_classes
Neo4j::ActiveNode::Labels::WRAPPED_CLASSES
end
- #add_label
adds one or more labels
ruby
def add_label(label) @_persisted_obj.add_label(label) end
.add_wrapped_class
ruby
- def self.add_wrapped_class(model)
_wrapped_classes << model
end
.clear_model_for_label_cache
ruby
- def self.clear_model_for_label_cache
MODELS_FOR_LABELS_CACHE.clear
end
.clear_wrapped_models
ruby
- def self.clear_wrapped_models
WRAPPED_CLASSES.clear
end
#labels
ruby
- def labels
@_persisted_obj.labels
end
.model_cache
ruby
- def self.model_cache(labels)
- models = WRAPPED_CLASSES.select do
(model.mapped_label_names - labels).size == 0
end
- MODELS_FOR_LABELS_CACHE[labels] = models.max do
(model.mapped_label_names & labels).size
end
end
.model_for_labels
ruby
- 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.
ruby
def remove_label(label) @_persisted_obj.remove_label(label) end