Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2014-06-13 14:34:15 +0400
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2014-06-13 14:34:15 +0400
commit87760a290eddbc35f4e89b129da6ec842a70f609 (patch)
tree7a77618425322e1c013b6b136e68657847134626 /lib/gitlab/url_builder.rb
parent45e1941fb3acf8fdc0544842ce503de007e3c706 (diff)
Added an UrlBuilder for building rails named routes
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
Diffstat (limited to 'lib/gitlab/url_builder.rb')
-rw-r--r--lib/gitlab/url_builder.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
new file mode 100644
index 00000000000..de7e0404086
--- /dev/null
+++ b/lib/gitlab/url_builder.rb
@@ -0,0 +1,25 @@
+module Gitlab
+ class UrlBuilder
+ include Rails.application.routes.url_helpers
+
+ def initialize(type)
+ @type = type
+ end
+
+ def build(id)
+ case @type
+ when :issue
+ issue_url(id)
+ end
+ end
+
+ private
+
+ def issue_url(id)
+ issue = Issue.find(id)
+ project_issue_url(id: issue.iid,
+ project_id: issue.project,
+ host: Settings.gitlab['url'])
+ end
+ end
+end