Module: ActiveGraph::Node::Wrapping

Defined in:
lib/active_graph/node/wrapping.rb

Constant Summary collapse

CONSTANTS_FOR_LABELS_CACHE =

Only load classes once for performance

{}

Class Method Summary collapse

Class Method Details

.class_to_wrap(labels) ⇒ Object



17
18
19
20
21
22
# File 'lib/active_graph/node/wrapping.rb', line 17

def class_to_wrap(labels)
  load_classes_from_labels(labels)
  ActiveGraph::Node::Labels.model_for_labels(labels).tap do |model_class|
    populate_constants_for_labels_cache(model_class, labels)
  end
end

.wrapper(node) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/active_graph/node/wrapping.rb', line 8

def wrapper(node)
  found_class = class_to_wrap(node.labels)
  return node unless found_class

  found_class.new.tap do |wrapped_node|
    wrapped_node.init_on_load(node, node.properties)
  end
end