Class: Gitlab::SubmoduleLinks

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/submodule_links.rb

Defined Under Namespace

Classes: Urls

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(repository) ⇒ SubmoduleLinks

Returns a new instance of SubmoduleLinks.


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

def initialize(repository)
  @repository = repository
  @cache_store = {}
end

Instance Method Details

#for(submodule, sha, diff_file = nil) ⇒ Object


14
15
16
17
18
19
# File 'lib/gitlab/submodule_links.rb', line 14

def for(submodule, sha, diff_file = nil)
  submodule_url = submodule_url_for(sha, submodule.path)
  old_submodule_id = old_submodule_id(submodule_url, diff_file)
  urls = SubmoduleHelper.submodule_links_for_url(submodule.id, submodule_url, repository, old_submodule_id)
  Urls.new(*urls) if urls.any?
end