summaryrefslogtreecommitdiff
path: root/app/models/external_issue.rb
blob: 68b2353556e32b7a43420fa65721c0041a167e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true

class ExternalIssue
  include Referable

  attr_reader :project

  def initialize(issue_identifier, project)
    @issue_identifier, @project = issue_identifier, project
  end

  def to_s
    @issue_identifier.to_s
  end

  def id
    @issue_identifier.to_s
  end

  def iid
    @issue_identifier.to_s
  end

  def title
    "External Issue #{self}"
  end

  def ==(other)
    other.is_a?(self.class) && (to_s == other.to_s)
  end
  alias_method :eql?, :==

  def hash
    [self.class, to_s].hash
  end

  def project_id
    project.id
  end

  def to_reference(_from = nil, full: nil)
    reference_link_text
  end

  def reference_link_text(from = nil)
    return "##{id}" if id =~ /^\d+$/

    id
  end

  def notes
    Note.none
  end
end