Class: BulkImports::FileTransfer::BaseConfig

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/models/bulk_imports/file_transfer/base_config.rb

Direct Known Subclasses

GroupConfig, ProjectConfig

Constant Summary collapse

UPLOADS_RELATION =
'uploads'
SELF_RELATION =
'self'

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(portable) ⇒ BaseConfig

Returns a new instance of BaseConfig.


11
12
13
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 11

def initialize(portable)
  @portable = portable
end

Instance Method Details

#export_pathObject


27
28
29
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 27

def export_path
  @export_path ||= Dir.mktmpdir('bulk_imports')
end

#file_relation?(relation) ⇒ Boolean

Returns:

  • (Boolean)

43
44
45
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 43

def file_relation?(relation)
  file_relations.include?(relation)
end

#portable_relationsObject


31
32
33
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 31

def portable_relations
  tree_relations + file_relations + self_relation - skipped_relations
end

#portable_relations_treeObject


53
54
55
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 53

def portable_relations_tree
  @portable_relations_tree ||= attributes_finder.find_relations_tree(portable_class_sym).deep_stringify_keys
end

#portable_treeObject


15
16
17
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 15

def portable_tree
  attributes_finder.find_root(portable_class_sym)
end

#relation_excluded_keys(relation) ⇒ Object


23
24
25
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 23

def relation_excluded_keys(relation)
  attributes_finder.find_excluded_keys(relation)
end

#self_relation?(relation) ⇒ Boolean

Returns:

  • (Boolean)

35
36
37
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 35

def self_relation?(relation)
  relation == SELF_RELATION
end

#top_relation_tree(relation) ⇒ Object


19
20
21
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 19

def top_relation_tree(relation)
  portable_relations_tree[relation.to_s]
end

#tree_relation?(relation) ⇒ Boolean

Returns:

  • (Boolean)

39
40
41
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 39

def tree_relation?(relation)
  tree_relations.include?(relation)
end

#tree_relation_definition_for(relation) ⇒ Object


47
48
49
50
51
# File 'app/models/bulk_imports/file_transfer/base_config.rb', line 47

def tree_relation_definition_for(relation)
  return unless tree_relation?(relation)

  portable_tree[:include].find { |include| include[relation.to_sym] }
end