2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Releases
|
|
|
|
class Link < ActiveRecord::Base
|
|
|
|
self.table_name = 'release_links'
|
|
|
|
|
|
|
|
belongs_to :release
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
validates :url, presence: true, url: true, uniqueness: { scope: :release }
|
2019-02-15 15:39:39 +05:30
|
|
|
validates :name, presence: true, uniqueness: { scope: :release }
|
|
|
|
|
|
|
|
scope :sorted, -> { order(created_at: :desc) }
|
|
|
|
|
|
|
|
def internal?
|
|
|
|
url.start_with?(release.project.web_url)
|
|
|
|
end
|
|
|
|
|
|
|
|
def external?
|
|
|
|
!internal?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|