6
6
require 'meilisearch/rails/multi_search'
7
7
require 'meilisearch/rails/index_settings'
8
8
require 'meilisearch/rails/safe_index'
9
+ require 'meilisearch/rails/model_configuration'
9
10
10
11
if defined? Rails
11
12
begin
@@ -73,7 +74,7 @@ class << base
73
74
alias_method :must_reindex? , :ms_must_reindex? unless method_defined? :must_reindex?
74
75
end
75
76
76
- base . cattr_accessor :meilisearch_options , :meilisearch_settings
77
+ base . cattr_accessor :meilisearch_options , :meilisearch_settings , :ms_config
77
78
end
78
79
79
80
def meilisearch ( options = { } , &block )
@@ -83,11 +84,9 @@ def meilisearch(options = {}, &block)
83
84
per_page : meilisearch_settings . get_setting ( :hitsPerPage ) || 20 , page : 1
84
85
} . merge ( options )
85
86
86
- attr_accessor :formatted
87
+ self . ms_config = ModelConfiguration . new ( model_name . to_s . constantize , options )
87
88
88
- if options . key? ( :per_environment )
89
- raise BadConfiguration , ':per_environment option should be defined globally on MeiliSearch::Rails.configuration block.'
90
- end
89
+ attr_accessor :formatted
91
90
92
91
if options [ :synchronous ] == true
93
92
if defined? ( ::Sequel ::Model ) && self < Sequel ::Model
@@ -104,8 +103,6 @@ def meilisearch(options = {}, &block)
104
103
end
105
104
end
106
105
if options [ :enqueue ]
107
- raise ArgumentError , 'Cannot use a enqueue if the `synchronous` option is set' if options [ :synchronous ]
108
-
109
106
proc = if options [ :enqueue ] == true
110
107
proc do |record , remove |
111
108
if remove
0 commit comments