Module: Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Routable

Included in:
Namespace, Project
Defined in:
lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb

Instance Method Summary collapse

Instance Method Details

#build_full_pathObject


19
20
21
22
23
24
25
# File 'lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb', line 19

def build_full_path
  if parent && path
    parent.full_path + '/' + path
  else
    path
  end
end

#full_pathObject


9
10
11
12
13
14
15
16
17
# File 'lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb', line 9

def full_path
  if route && route.path.present?
    @full_path ||= route.path # rubocop:disable Gitlab/ModuleWithInstanceVariables
  else
    update_route if persisted?

    build_full_path
  end
end

#prepare_routeObject


32
33
34
35
36
# File 'lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb', line 32

def prepare_route
  route || build_route(source: self)
  route.path = build_full_path
  @full_path = nil # rubocop:disable Gitlab/ModuleWithInstanceVariables
end

#update_routeObject


27
28
29
30
# File 'lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb', line 27

def update_route
  prepare_route
  route.save
end