2016-06-02 11:05:42 +05:30
|
|
|
module Gitlab
|
|
|
|
module Routing
|
2017-08-17 22:00:37 +05:30
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
mattr_accessor :_includers
|
|
|
|
self._includers = []
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
included do
|
2017-09-10 17:25:29 +05:30
|
|
|
Gitlab::Routing.includes_helpers(self)
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
def self.includes_helpers(klass)
|
|
|
|
self._includers << klass
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.add_helpers(mod)
|
|
|
|
url_helpers.include mod
|
|
|
|
url_helpers.extend mod
|
|
|
|
|
|
|
|
GitlabRoutingHelper.include mod
|
|
|
|
GitlabRoutingHelper.extend mod
|
|
|
|
|
|
|
|
app_url_helpers = Gitlab::Application.routes.named_routes.url_helpers_module
|
|
|
|
app_url_helpers.include mod
|
|
|
|
app_url_helpers.extend mod
|
|
|
|
|
|
|
|
_includers.each do |klass|
|
|
|
|
klass.include mod
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
# Returns the URL helpers Module.
|
|
|
|
#
|
|
|
|
# This method caches the output as Rails' "url_helpers" method creates an
|
|
|
|
# anonymous module every time it's called.
|
|
|
|
#
|
|
|
|
# Returns a Module.
|
|
|
|
def self.url_helpers
|
|
|
|
@url_helpers ||= Gitlab::Application.routes.url_helpers
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|