module Rooftop::AlgoliaSearch::PostIndexing
Public Class Methods
included(base)
click to toggle source
# File lib/rooftop/algolia_search/post_indexing.rb, line 5 def self.included(base) base.extend ClassMethods base.send :setup_index_name! base.send :after_save, :reindex! base.send :after_destroy, :deindex! end
Public Instance Methods
deindex!()
click to toggle source
# File lib/rooftop/algolia_search/post_indexing.rb, line 92 def deindex! self.class.deindex_entity(self) end
reindex!()
click to toggle source
Reindex an instance
# File lib/rooftop/algolia_search/post_indexing.rb, line 81 def reindex! # only reindex things which are published if status == 'publish' self.class.reindex_entity(self) else deindex! end end
Also aliased as: index!
to_search_index_parameters()
click to toggle source
# File lib/rooftop/algolia_search/post_indexing.rb, line 96 def to_search_index_parameters self.class.search_fields.inject({}) do |hash, fields| hash[:objectID] = self.id if fields.last.is_a? Proc hash[fields.first] = fields.last.call(self) else fields.each do |field| begin hash[field] = self.send(field) rescue NoMethodError if self.has_field?(field) hash[field] = self.fields.send(field) end end end end hash end end