diff options
author | Jeroen van Baarsen <jeroenvanbaarsen@gmail.com> | 2014-06-13 14:34:15 +0400 |
---|---|---|
committer | Jeroen van Baarsen <jeroenvanbaarsen@gmail.com> | 2014-06-13 14:34:15 +0400 |
commit | 87760a290eddbc35f4e89b129da6ec842a70f609 (patch) | |
tree | 7a77618425322e1c013b6b136e68657847134626 /lib/gitlab | |
parent | 45e1941fb3acf8fdc0544842ce503de007e3c706 (diff) |
Added an UrlBuilder for building rails named routes
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/url_builder.rb | 25 |
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 |