@@ -88,7 +88,7 @@ def meilisearch(options = {}, &block)
8888 attr_accessor :formatted
8989
9090 if options [ :synchronous ] == true
91- if defined? ( :: Sequel :: Model ) && self < Sequel :: Model
91+ if ms_config . sequel_model?
9292 class_eval do
9393 copy_after_validation = instance_method ( :after_validation )
9494 define_method ( :after_validation ) do |*args |
@@ -122,7 +122,7 @@ def meilisearch(options = {}, &block)
122122 end
123123 end
124124 unless options [ :auto_index ] == false
125- if defined? ( :: Sequel :: Model ) && self < Sequel :: Model
125+ if ms_config . sequel_model?
126126 class_eval do
127127 copy_after_validation = instance_method ( :after_validation )
128128 copy_before_save = instance_method ( :before_save )
@@ -169,7 +169,7 @@ def meilisearch(options = {}, &block)
169169 end
170170 end
171171 unless options [ :auto_remove ] == false
172- if defined? ( :: Sequel :: Model ) && self < Sequel :: Model
172+ if ms_config . sequel_model?
173173 class_eval do
174174 copy_after_destroy = instance_method ( :after_destroy )
175175
@@ -391,7 +391,7 @@ def ms_search(query, params = {})
391391 # The condition_key must be a valid column otherwise, the `.where` below will not work
392392 # Since we provide a way to customize the primary_key value, `ms_pk(meilisearch_options)` may not
393393 # respond with a valid database column. The blocks below prevent that from happening.
394- has_virtual_column_as_pk = if defined? ( :: Sequel :: Model ) && self < Sequel :: Model
394+ has_virtual_column_as_pk = if ms_config . sequel_model?
395395 columns . map ( &:to_s ) . exclude? ( condition_key . to_s )
396396 else
397397 columns . map ( &:name ) . map ( &:to_s ) . exclude? ( condition_key . to_s )
@@ -591,10 +591,10 @@ def ms_indexing_disabled?(options = nil)
591591 end
592592
593593 def ms_find_in_batches ( batch_size , &block )
594- if ( defined? ( :: ActiveRecord ) && ancestors . include? ( :: ActiveRecord :: Base ) ) || respond_to? ( :find_in_batches )
594+ if ms_config . active_record_model? || respond_to? ( :find_in_batches )
595595 scope = respond_to? ( :meilisearch_import ) ? meilisearch_import : all
596596 scope . find_in_batches ( batch_size : batch_size , &block )
597- elsif defined? ( :: Sequel :: Model ) && self < Sequel :: Model
597+ elsif ms_config . sequel_model?
598598 dataset . extension ( :pagination ) . each_page ( batch_size , &block )
599599 else
600600 # don't worry, mongoid has its own underlying cursor/streaming mechanism
@@ -682,7 +682,7 @@ def ms_mark_must_reindex
682682 # ms_must_reindex flag is reset after every commit as part. If we must reindex at any point in
683683 # a transaction, keep flag set until it is explicitly unset
684684 @ms_must_reindex ||=
685- if defined? ( :: Sequel :: Model ) && is_a? ( Sequel :: Model )
685+ if self . class . ms_config . sequel_model?
686686 new? || self . class . ms_must_reindex? ( self )
687687 else
688688 new_record? || self . class . ms_must_reindex? ( self )
0 commit comments