lib/grape/dsl/settings.rb in grape-1.2.5 vs lib/grape/dsl/settings.rb in grape-1.3.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'active_support/concern'
module Grape
module DSL
# Keeps track of settings (implemented as key-value pairs, grouped by
@@ -167,10 +169,14 @@
# Builds the current class :inheritable_setting. If available, it inherits from
# the superclass's :inheritable_setting.
def build_top_level_setting
Grape::Util::InheritableSetting.new.tap do |setting|
- if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API
+ # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to
+ # +inheritable_setting+, however, it doesn't contain any user-defined settings.
+ # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+
+ # in the chain for every endpoint.
+ if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance
setting.inherit_from superclass.inheritable_setting
end
end
end
end