Class: Graphable::IndexCreator
- Inherits:
-
Object
- Object
- Graphable::IndexCreator
- Extended by:
- Forwardable
- Defined in:
- lib/graphable/index_creator.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(klass, method) ⇒ IndexCreator
constructor
A new instance of IndexCreator.
Constructor Details
#initialize(klass, method) ⇒ IndexCreator
Returns a new instance of IndexCreator.
8 9 10 11 |
# File 'lib/graphable/index_creator.rb', line 8 def initialize(klass, method) @klass = klass @method = method end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/graphable/index_creator.rb', line 5 def klass @klass end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/graphable/index_creator.rb', line 13 def call return if Graphable.has_indexed?(@klass, @method) puts "Building #{@method} index for #{name}" Graphable.neo.create_node_index(graph_index_name, 'exact') # fulltext Graphable.objects_of(@klass).each_slice(250) do |slice| Graphable.neo.batch(*slice.map do |obj| [:add_node_to_index, graph_index_name, @method, obj.send(@method), Graphable.index_cache[obj]] end) end Graphable.completed_index(@klass, @method) end |