Class: Gitlab::UrlBuilder

Inherits:
Object
  • Object
show all
Includes:
ActionView::RecordIdentifier, GitlabRoutingHelper
Defined in:
lib/gitlab/url_builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object


7
8
9
# File 'lib/gitlab/url_builder.rb', line 7

def object
  @object
end

Class Method Details

.build(object) ⇒ Object


9
10
11
# File 'lib/gitlab/url_builder.rb', line 9

def self.build(object)
  new(object).url
end

Instance Method Details

#urlObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/url_builder.rb', line 13

def url
  case object
  when Commit
    commit_url
  when Issue
    issue_url(object)
  when MergeRequest
    merge_request_url(object)
  when Note
    note_url
  when WikiPage
    wiki_page_url
  else
    raise NotImplementedError.new("No URL builder defined for #{object.class}")
  end
end