Class: Pose::Jobs::ReindexAll

Inherits:
Object
  • Object
show all
Defined in:
lib/pose/jobs/reindex_all.rb

Overview

Recreates the Pose search index for the given class from scratch.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz) ⇒ ReindexAll

Returns a new instance of ReindexAll.

Parameters:

  • clazz (String, Class)


11
12
13
14
15
16
17
18
19
20
# File 'lib/pose/jobs/reindex_all.rb', line 11

def initialize(clazz)
  @klass = case clazz
             when String
               clazz.constantize
             when Class
               clazz
             else
               raise ArgumentError, "Class or String expected, #{clazz.class} given"
           end
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



8
9
10
# File 'lib/pose/jobs/reindex_all.rb', line 8

def klass
  @klass
end

Instance Method Details

#performObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/pose/jobs/reindex_all.rb', line 22

def perform
  progress_bar = ProgressBar.create title: "  reindexing", total: klass.count

  klass.find_each do |instance|
    instance.update_pose_words
    progress_bar.increment
  end

  progress_bar.finish
end