Skip to content

Commit ce4966d

Browse files
committed
Better handles constants
1 parent 9416023 commit ce4966d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/grape/api.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module Grape
66
# should subclass this class in order to build an API.
77
class API
88
# Class methods that we want to call on the API rather than on the API object
9-
NON_OVERRIDABLE = %I[define_singleton_method instance_variable_set inspect class is_a? ! kind_of? respond_to? const_defined? const_missing].freeze
9+
NON_OVERRIDABLE = %I[define_singleton_method instance_variable_set inspect class is_a? ! kind_of?
10+
respond_to? const_defined? const_missing parent parent_name name equal? to_s parents].freeze
1011

1112
class << self
1213
attr_accessor :base_instance, :instances
@@ -48,7 +49,9 @@ def api.inherited(child_api)
4849
# Alleviates problems with autoloading by tring to search for the constant
4950
def const_missing(*args)
5051
if base_instance.const_defined?(*args)
51-
base_instance.const_missing(*args)
52+
base_instance.const_get(*args)
53+
elsif parent && parent.const_defined?(*args)
54+
parent.const_get(*args)
5255
else
5356
super
5457
end

0 commit comments

Comments
 (0)