Module: SearchFlip::Model::ClassMethods

Defined in:
lib/search_flip/model.rb

Instance Method Summary collapse

Instance Method Details

#notifies_index(index) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/search_flip/model.rb', line 8

def notifies_index(index)
  if respond_to?(:after_commit)
    after_commit { |record| record.destroyed? ? index.delete(record) : index.import(record) }
  else
    after_save { |record| index.import(record) }
    after_touch { |record| index.import(record) } if respond_to?(:after_touch)
    after_destroy { |record| index.delete(record) }
  end
end