external_issue.rb 773 Bytes
Newer Older
1 2
# frozen_string_literal: true

3
class ExternalIssue
4 5
  include Referable

6 7
  attr_reader :project

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  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

24 25 26 27
  def title
    "External Issue #{self}"
  end

28 29 30
  def ==(other)
    other.is_a?(self.class) && (to_s == other.to_s)
  end
31 32 33 34 35
  alias_method :eql?, :==

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

37
  def project_id
38
    project.id
39 40
  end

41
  def to_reference(_from = nil, full: nil)
42
    reference_link_text
43
  end
44

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

    id
49
  end
50 51 52 53

  def notes
    Note.none
  end
54
end