Class: Pages::LookupPath

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/models/pages/lookup_path.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(project, trim_prefix: nil, domain: nil) ⇒ LookupPath

Returns a new instance of LookupPath.


7
8
9
10
11
# File 'app/models/pages/lookup_path.rb', line 7

def initialize(project, trim_prefix: nil, domain: nil)
  @project = project
  @domain = domain
  @trim_prefix = trim_prefix || project.full_path
end

Instance Method Details

#access_controlObject


17
18
19
# File 'app/models/pages/lookup_path.rb', line 17

def access_control
  project.private_pages?
end

#https_onlyObject


21
22
23
24
# File 'app/models/pages/lookup_path.rb', line 21

def https_only
  domain_https = domain ? domain.https? : true
  project.pages_https_only? && domain_https
end

#prefixObject


30
31
32
33
34
35
36
# File 'app/models/pages/lookup_path.rb', line 30

def prefix
  if project.pages_group_root?
    '/'
  else
    project.full_path.delete_prefix(trim_prefix) + '/'
  end
end

#project_idObject


13
14
15
# File 'app/models/pages/lookup_path.rb', line 13

def project_id
  project.id
end

#sourceObject


26
27
28
# File 'app/models/pages/lookup_path.rb', line 26

def source
  zip_source || file_source
end