Class: Gitlab::ImportExport::AttributesFinder
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::AttributesFinder
- Defined in:
- lib/gitlab/import_export/attributes_finder.rb
Instance Attribute Summary collapse
-
#excluded_attributes ⇒ Object
readonly
Returns the value of attribute excluded_attributes.
-
#export_reorders ⇒ Object
readonly
Returns the value of attribute export_reorders.
-
#import_only_tree ⇒ Object
readonly
Returns the value of attribute import_only_tree.
-
#included_attributes ⇒ Object
readonly
Returns the value of attribute included_attributes.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#preloads ⇒ Object
readonly
Returns the value of attribute preloads.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
- #find_excluded_keys(klass_name) ⇒ Object
- #find_relations_tree(model_key, include_import_only_tree: false) ⇒ Object
- #find_root(model_key) ⇒ Object
-
#initialize(config:) ⇒ AttributesFinder
constructor
A new instance of AttributesFinder.
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_attributes ⇒ Object (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_reorders ⇒ Object (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_tree ⇒ Object (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_attributes ⇒ Object (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 |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
6 7 8 |
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6 def methods @methods end |
#preloads ⇒ Object (readonly)
Returns the value of attribute preloads.
6 7 8 |
# File 'lib/gitlab/import_export/attributes_finder.rb', line 6 def preloads @preloads end |
#tree ⇒ Object (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 |