Skip to content

Commit c283642

Browse files
committed
Simplify deprecation logic for spelling change
1 parent 2e61252 commit c283642

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

lib/meilisearch.rb

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,18 @@
1515
module Meilisearch
1616
end
1717

18+
# Softly deprecate the old spelling of the top level module
19+
# from MeiliSearch to Meilisearch
1820
module MeiliSearch
1921
class << self
20-
# Softly deprecate the old spelling of the top level module
21-
# from MeiliSearch to Meilisearch
2222
def const_missing(const_name)
23-
return super if @warned && @constants_defined
24-
2523
_warn_about_deprecation
26-
_define_constants
2724

28-
# Now that all the proper constants have been set,
29-
# we can tell ruby to search for the const in MeiliSearch again.
30-
# If it's still not found, then it does not exist in
31-
# Meilisearch and the call to `super` will throw a normal error
32-
const_get(const_name)
25+
Meilisearch.const_get(const_name)
3326
end
3427

3528
def method_missing(method_name, *args, **kwargs)
3629
_warn_about_deprecation
37-
_define_constants
3830

3931
Meilisearch.send(method_name, *args, **kwargs)
4032
end
@@ -55,15 +47,5 @@ def _warn_about_deprecation
5547

5648
@warned = true
5749
end
58-
59-
def _define_constants
60-
return if @constants_defined
61-
62-
Meilisearch.constants.each do |constant|
63-
const_set(constant, Meilisearch.const_get(constant))
64-
end
65-
66-
@constants_defined = true
67-
end
6850
end
6951
end

0 commit comments

Comments
 (0)