module AgnosticBackend::Indexable::InstanceMethods
Public Instance Methods
generate_document(for_index: nil, observer: nil)
click to toggle source
# File lib/agnostic_backend/indexable/indexable.rb, line 96 def generate_document(for_index: nil, observer: nil) index_name = for_index.nil? ? self.index_name : for_index.to_s return unless respond_to? :_index_content_managers manager = _index_content_managers[index_name.to_s] raise "Index #{index_name} does not exist" if manager.nil? observer ||= AgnosticBackend::Indexable::ObjectObserver.new manager.extract_contents_from self, index_name, observer: observer end
index_name(source=nil)
click to toggle source
# File lib/agnostic_backend/indexable/indexable.rb, line 92 def index_name(source=nil) self.class.index_name(source) end
index_object(index_name)
click to toggle source
# File lib/agnostic_backend/indexable/indexable.rb, line 116 def index_object(index_name) put_to_index(index_name) end
put_to_index(index_name=nil)
click to toggle source
# File lib/agnostic_backend/indexable/indexable.rb, line 105 def put_to_index(index_name=nil) indexable_class = index_name.nil? ? self.class : AgnosticBackend::Indexable.indexable_class(index_name) indexable_class.create_indices.map do |index| indexer = index.indexer indexer.put(self) end end
Private Instance Methods
trigger_index_notification()
click to toggle source
# File lib/agnostic_backend/indexable/indexable.rb, line 122 def trigger_index_notification return unless respond_to? :_index_root_notifiers _index_root_notifiers.each do |index_name, block| obj = instance_eval &block obj = [obj] unless obj.respond_to? :each obj.each { |o| o.index_object(index_name) if o.present? } end end