debian-mirror-gitlab/app/models/design_management/repository.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
734 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module DesignManagement
2023-06-20 00:43:36 +05:30
class Repository < ApplicationRecord
include ::Gitlab::Utils::StrongMemoize
2020-05-24 23:13:21 +05:30
2023-06-20 00:43:36 +05:30
belongs_to :project, inverse_of: :design_management_repository
validates :project, presence: true, uniqueness: true
2020-05-24 23:13:21 +05:30
2023-06-20 00:43:36 +05:30
# This is so that git_repo is initialized once `project` has been
# set. If it is not set after intialization and saving the record
# fails for some reason, the first call to `git_repo`` (initiated by
# `delegate_missing_to`) will throw an error because project would
# be missing.
after_initialize :git_repo
2020-05-24 23:13:21 +05:30
2023-06-20 00:43:36 +05:30
delegate_missing_to :git_repo
2020-05-24 23:13:21 +05:30
2023-06-20 00:43:36 +05:30
def git_repo
GitRepository.new(project)
2020-05-24 23:13:21 +05:30
end
2023-06-20 00:43:36 +05:30
strong_memoize_attr :git_repo
2020-05-24 23:13:21 +05:30
end
end