Module: Gitlab::Routing

Defined Under Namespace

Classes: LegacyRedirector

Class Method Summary collapse

Class Method Details

.add_helpers(mod) ⇒ Object


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gitlab/routing.rb', line 50

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

.includes_helpers(klass) ⇒ Object


46
47
48
# File 'lib/gitlab/routing.rb', line 46

def self.includes_helpers(klass)
  self._includers << klass
end

.redirect_legacy_paths(router, *paths) ⇒ Object


76
77
78
79
80
81
82
83
# File 'lib/gitlab/routing.rb', line 76

def self.redirect_legacy_paths(router, *paths)
  paths.each do |path|
    router.match "/#{path}(/*rest)",
                 via: [:get, :post, :patch, :delete],
                 to: router.redirect(LegacyRedirector.new(path)),
                 as: "legacy_#{path}_redirect"
  end
end

.url_helpersObject

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.


72
73
74
# File 'lib/gitlab/routing.rb', line 72

def self.url_helpers
  @url_helpers ||= Gitlab::Application.routes.url_helpers
end