Class: Gitlab::ImportExport::AttributesFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/import_export/attributes_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ AttributesFinder

Returns a new instance of AttributesFinder.



9
10
11
12
13
14
15
16
17
18
# File 'lib/gitlab/import_export/attributes_finder.rb', line 9

def initialize(config:)
  @tree = config[:tree] || {}
  @included_attributes = config[:included_attributes] || {}
  @excluded_attributes = config[:excluded_attributes] || {}
  @methods = config[:methods] || {}
  @preloads = config[:preloads] || {}
  @export_reorders = config[:export_reorders] || {}
  @include_if_exportable = config[:include_if_exportable] || {}
  @import_only_tree = config[:import_only_tree] || {}
end

Instance Attribute Details

#excluded_attributesObject (readonly)

Returns the value of attribute excluded_attributes.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def excluded_attributes
  @excluded_attributes
end

#export_reordersObject (readonly)

Returns the value of attribute export_reorders.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def export_reorders
  @export_reorders
end

#import_only_treeObject (readonly)

Returns the value of attribute import_only_tree.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def import_only_tree
  @import_only_tree
end

#included_attributesObject (readonly)

Returns the value of attribute included_attributes.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def included_attributes
  @included_attributes
end

#methodsObject (readonly)

Returns the value of attribute methods.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def methods
  @methods
end

#preloadsObject (readonly)

Returns the value of attribute preloads.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def preloads
  @preloads
end

#treeObject (readonly)

Returns the value of attribute tree.



6
7
8
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6

def tree
  @tree
end

Instance Method Details

#find_excluded_keys(klass_name) ⇒ Object



30
31
32
# File 'lib/gitlab/import_export/attributes_finder.rb', line 30

def find_excluded_keys(klass_name)
  @excluded_attributes[klass_name.to_sym]&.map(&:to_s) || []
end

#find_relations_tree(model_key, include_import_only_tree: false) ⇒ Object



24
25
26
27
28
# File 'lib/gitlab/import_export/attributes_finder.rb', line 24

def find_relations_tree(model_key, include_import_only_tree: false)
  return @tree[model_key].deep_merge(@import_only_tree[model_key] || {}) if include_import_only_tree

  @tree[model_key]
end

#find_root(model_key) ⇒ Object



20
21
22
# File 'lib/gitlab/import_export/attributes_finder.rb', line 20

def find_root(model_key)
  find(model_key, @tree[model_key])
end