Commit 1d787b38 authored by Sean McGivern's avatar Sean McGivern

Only expose needed methods from API::Base

parent 2a9401dd
...@@ -4,24 +4,28 @@ module API ...@@ -4,24 +4,28 @@ module API
class Base < Grape::API::Instance # rubocop:disable API/Base class Base < Grape::API::Instance # rubocop:disable API/Base
include ::Gitlab::WithFeatureCategory include ::Gitlab::WithFeatureCategory
def self.feature_category_for_app(app) class << self
feature_category_for_action(path_for_app(app)) def feature_category_for_app(app)
end feature_category_for_action(path_for_app(app))
end
def self.path_for_app(app) def path_for_app(app)
normalize_path(app.namespace, app.options[:path].first) normalize_path(app.namespace, app.options[:path].first)
end end
def self.route(methods, paths = ['/'], route_options = {}, &block) def route(methods, paths = ['/'], route_options = {}, &block)
if category = route_options.delete(:feature_category) if category = route_options.delete(:feature_category)
feature_category(category, Array(paths).map { |path| normalize_path(namespace, path) }) feature_category(category, Array(paths).map { |path| normalize_path(namespace, path) })
end
super
end end
super private
end
def self.normalize_path(namespace, path) def normalize_path(namespace, path)
[namespace.presence, path.to_s.chomp('/').presence].compact.join('/') [namespace.presence, path.to_s.chomp('/').presence].compact.join('/')
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment