@@ -20,29 +20,23 @@ class << self
2020 # Softly deprecate the old spelling of the top level module
2121 # from MeiliSearch to Meilisearch
2222 def const_missing ( const_name )
23- return super if @warned
23+ return super if @warned && @constants_defined
2424
2525 _warn_about_deprecation
2626 _define_constants
2727
28- @warned = true
29-
3028 # Now that all the proper constants have been set,
3129 # we can tell ruby to search for the const in MeiliSearch again.
3230 # If it's still not found, then it does not exist in
3331 # Meilisearch and the call to `super` will throw a normal error
3432 const_get ( const_name )
3533 end
3634
37- def method_missing ( method_name )
38- unless @warned
39- _warn_about_deprecation
40- _define_constants
41- end
42-
43- @warned = true
35+ def method_missing ( method_name , *args , **kwargs )
36+ _warn_about_deprecation
37+ _define_constants
4438
45- Meilisearch . send ( method_name )
39+ Meilisearch . send ( method_name , * args , ** kwargs )
4640 end
4741
4842 def respond_to_missing? ( method_name , *)
@@ -52,16 +46,24 @@ def respond_to_missing?(method_name, *)
5246 private
5347
5448 def _warn_about_deprecation
49+ return if @warned
50+
5551 Meilisearch ::Utils . logger . warn <<~RENAMED_MODULE_WARNING
5652 [meilisearch-ruby] The top-level module of Meilisearch has been renamed.
5753 [meilisearch-ruby] Please update "MeiliSearch" to "Meilisearch".
5854 RENAMED_MODULE_WARNING
55+
56+ @warned = true
5957 end
6058
6159 def _define_constants
60+ return if @constants_defined
61+
6262 Meilisearch . constants . each do |constant |
6363 const_set ( constant , Meilisearch . const_get ( constant ) )
6464 end
65+
66+ @constants_defined = true
6567 end
6668 end
6769end
0 commit comments