File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1414
1515module Meilisearch
1616end
17+
18+ module MeiliSearch
19+ # Softly deprecate the old spelling of the top level module
20+ # from MeiliSearch to Meilisearch
21+ def self . const_missing ( const_name )
22+ return super if @warned
23+
24+ Meilisearch ::Utils . logger . warn <<~RENAMED_MODULE_WARNING
25+ [meilisearch-ruby] The top-level module of Meilisearch has been renamed.
26+ [meilisearch-ruby] Please update "MeiliSearch" to "Meilisearch".
27+ RENAMED_MODULE_WARNING
28+
29+ Meilisearch . constants . each do |constant |
30+ const_set ( constant , Meilisearch . const_get ( constant ) )
31+ end
32+
33+ @warned = true
34+
35+ # Now that all the proper constants have been set,
36+ # we can tell ruby to search for the const in MeiliSearch again.
37+ # If it's still not found, then it does not exist in
38+ # Meilisearch and the call to `super` will throw a normal error
39+ const_get ( const_name )
40+ end
41+
42+ def self . method_missing ( method_name )
43+ unless @warned
44+ Meilisearch ::Utils . logger . warn <<~RENAMED_MODULE_WARNING
45+ [meilisearch-ruby] The top-level module of Meilisearch has been renamed.
46+ [meilisearch-ruby] Please update "MeiliSearch" to "Meilisearch".
47+ RENAMED_MODULE_WARNING
48+
49+ Meilisearch . constants . each do |constant |
50+ const_set ( constant , Meilisearch . const_get ( constant ) )
51+ end
52+ end
53+
54+ @warned = true
55+
56+ Meilisearch . send ( method_name )
57+ end
58+ end
You can’t perform that action at this time.
0 commit comments