Module: Hari::Node::Repository

Extended by:
ActiveSupport::Concern
Included in:
Hari::Node
Defined in:
lib/hari/node/repository.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#reindex(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hari/node/repository.rb', line 6

def reindex(options = {})
  self.class.indexed_properties.each do |property|
    if change = previous_changes[property.name]
      previous, current = change

      Index.new(property, previous).delete self
      Index.new(property, current).add self
    elsif options[:force_index]
      value = send(property.name)
      Index.new(property, value).add self
    end
  end
end

#remove_from_indexesObject



20
21
22
23
24
25
# File 'lib/hari/node/repository.rb', line 20

def remove_from_indexes
  self.class.indexed_properties.each do |property|
    value = send(property.name)
    Index.new(property, value).delete self
  end
end