module Neo4j::ActiveNode::Labels
Provides a mapping between neo4j labels and Ruby classes
Constants
- MODELS_FOR_LABELS_CACHE
- WRAPPED_CLASSES
Public Class Methods
_wrapped_classes()
click to toggle source
# File lib/neo4j/active_node/labels.rb 45 def self._wrapped_classes 46 WRAPPED_CLASSES 47 end
add_wrapped_class(model)
click to toggle source
# File lib/neo4j/active_node/labels.rb 49 def self.add_wrapped_class(model) 50 _wrapped_classes << model 51 end
clear_wrapped_models()
click to toggle source
# File lib/neo4j/active_node/labels.rb 67 def self.clear_wrapped_models 68 MODELS_FOR_LABELS_CACHE.clear 69 Neo4j::Node::Wrapper::CONSTANTS_FOR_LABELS_CACHE.clear 70 end
model_for_labels(labels)
click to toggle source
Finds an appropriate matching model given a set of labels which are assigned to a node
# File lib/neo4j/active_node/labels.rb 55 def self.model_for_labels(labels) 56 return MODELS_FOR_LABELS_CACHE[labels] if MODELS_FOR_LABELS_CACHE[labels] 57 58 models = WRAPPED_CLASSES.select do |model| 59 (model.mapped_label_names - labels).size == 0 60 end 61 62 MODELS_FOR_LABELS_CACHE[labels] = models.max_by do |model| 63 (model.mapped_label_names & labels).size 64 end 65 end
Public Instance Methods
add_label(*label)
click to toggle source
adds one or more labels @see Neo4j-core
# File lib/neo4j/active_node/labels.rb 34 def add_label(*label) 35 @_persisted_obj.add_label(*label) 36 end
labels()
click to toggle source
@return the labels @see Neo4j-core
# File lib/neo4j/active_node/labels.rb 23 def labels 24 @_persisted_obj.labels 25 end
remove_label(*label)
click to toggle source
Removes one or more labels Be careful, don’t remove the label representing the Ruby class. @see Neo4j-core
# File lib/neo4j/active_node/labels.rb 41 def remove_label(*label) 42 @_persisted_obj.remove_label(*label) 43 end