Module: MeiliSearch::Rails::InstanceMethods

Defined in:
lib/meilisearch-rails.rb

Overview

these are the instance methods included

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



885
886
887
888
889
890
# File 'lib/meilisearch-rails.rb', line 885

def self.included(base)
  base.instance_eval do
    alias_method :index!, :ms_index! unless method_defined? :index!
    alias_method :remove_from_index!, :ms_remove_from_index! unless method_defined? :remove_from_index!
  end
end

Instance Method Details

#ms_enqueue_index!(synchronous) ⇒ Object



910
911
912
913
914
915
916
917
918
919
920
# File 'lib/meilisearch-rails.rb', line 910

def ms_enqueue_index!(synchronous)
  return unless Utilities.indexable?(self, meilisearch_options)

  if meilisearch_options[:enqueue]
    unless self.class.send(:ms_indexing_disabled?, meilisearch_options)
      meilisearch_options[:enqueue].call(self, false)
    end
  else
    ms_index!(synchronous)
  end
end

#ms_enqueue_remove_from_index!(synchronous) ⇒ Object



900
901
902
903
904
905
906
907
908
# File 'lib/meilisearch-rails.rb', line 900

def ms_enqueue_remove_from_index!(synchronous)
  if meilisearch_options[:enqueue]
    unless self.class.send(:ms_indexing_disabled?, meilisearch_options)
      meilisearch_options[:enqueue].call(self, true)
    end
  else
    ms_remove_from_index!(synchronous || ms_synchronous?)
  end
end

#ms_index!(synchronous = false) ⇒ Object



892
893
894
# File 'lib/meilisearch-rails.rb', line 892

def ms_index!(synchronous = false)
  self.class.ms_index!(self, synchronous || ms_synchronous?)
end

#ms_remove_from_index!(synchronous = false) ⇒ Object



896
897
898
# File 'lib/meilisearch-rails.rb', line 896

def ms_remove_from_index!(synchronous = false)
  self.class.ms_remove_from_index!(self, synchronous || ms_synchronous?)
end

#ms_synchronous?Boolean



922
923
924
# File 'lib/meilisearch-rails.rb', line 922

def ms_synchronous?
  @ms_synchronous
end