Class: Graphable::NodeCreator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/graphable/node_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ NodeCreator

Returns a new instance of NodeCreator.



10
11
12
# File 'lib/graphable/node_creator.rb', line 10

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



7
8
9
# File 'lib/graphable/node_creator.rb', line 7

def klass
  @klass
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/graphable/node_creator.rb', line 14

def call 
  puts "Building nodes for #{name}"
  Graphable.objects_of(@klass).each_slice(250) do |slice|
    nodes = Graphable.neo.batch(*slice.map do |obj| 
      [:create_node, obj.to_node]
    end)
    slice.zip(nodes).each do |object, node|
      Graphable.index_cache[object] = node["body"]
    end
  end
end