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



923
924
925
926
927
928
# File 'lib/meilisearch-rails.rb', line 923

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



948
949
950
951
952
953
954
955
956
957
958
# File 'lib/meilisearch-rails.rb', line 948

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



938
939
940
941
942
943
944
945
946
# File 'lib/meilisearch-rails.rb', line 938

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_entries(synchronous = false) ⇒ Object



964
965
966
# File 'lib/meilisearch-rails.rb', line 964

def ms_entries(synchronous = false)
  self.class.ms_entries_for(document: self, synchronous: synchronous || ms_synchronous?)
end

#ms_index!(synchronous = false) ⇒ Object



930
931
932
# File 'lib/meilisearch-rails.rb', line 930

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

#ms_remove_from_index!(synchronous = false) ⇒ Object



934
935
936
# File 'lib/meilisearch-rails.rb', line 934

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

#ms_synchronous?Boolean

Returns:

  • (Boolean)


960
961
962
# File 'lib/meilisearch-rails.rb', line 960

def ms_synchronous?
  @ms_synchronous
end