Class: Gitlab::ImportExport::Group::LegacyTreeRestorer
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::Group::LegacyTreeRestorer
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/import_export/group/legacy_tree_restorer.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#shared ⇒ Object
readonly
Returns the value of attribute shared.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user:, shared:, group:, group_hash:) ⇒ LegacyTreeRestorer
constructor
A new instance of LegacyTreeRestorer.
- #restore ⇒ Object
Methods included from Utils::StrongMemoize
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(user:, shared:, group:, group_hash:) ⇒ LegacyTreeRestorer
Returns a new instance of LegacyTreeRestorer.
13 14 15 16 17 18 |
# File 'lib/gitlab/import_export/group/legacy_tree_restorer.rb', line 13 def initialize(user:, shared:, group:, group_hash:) @user = user @shared = shared @group = group @group_hash = group_hash end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group
11 12 13 |
# File 'lib/gitlab/import_export/group/legacy_tree_restorer.rb', line 11 def group @group end |
#shared ⇒ Object (readonly)
Returns the value of attribute shared
10 11 12 |
# File 'lib/gitlab/import_export/group/legacy_tree_restorer.rb', line 10 def shared @shared end |
#user ⇒ Object (readonly)
Returns the value of attribute user
9 10 11 |
# File 'lib/gitlab/import_export/group/legacy_tree_restorer.rb', line 9 def user @user end |
Instance Method Details
#restore ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gitlab/import_export/group/legacy_tree_restorer.rb', line 20 def restore @group_attributes = relation_reader.consume_attributes(nil) @group_members = relation_reader.consume_relation(nil, 'members') .map(&:first) # We need to remove `name` and `path` as we did consume it in previous pass @group_attributes.delete('name') @group_attributes.delete('path') @children = @group_attributes.delete('children') if members_mapper.map && restorer.restore @children&.each do |group_hash| group = create_group(group_hash: group_hash, parent_group: @group) shared = Gitlab::ImportExport::Shared.new(group) self.class.new( user: @user, shared: shared, group: group, group_hash: group_hash ).restore end end return false if @shared.errors.any? true rescue => e @shared.error(e) false end |