Class: Gitlab::ImportExport::Group::TreeSaver
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::Group::TreeSaver
- Defined in:
- lib/gitlab/import_export/group/tree_saver.rb
Instance Attribute Summary collapse
-
#full_path ⇒ Object
readonly
Returns the value of attribute full_path.
-
#shared ⇒ Object
readonly
Returns the value of attribute shared.
Instance Method Summary collapse
-
#initialize(group:, current_user:, shared:, params: {}) ⇒ TreeSaver
constructor
A new instance of TreeSaver.
- #save ⇒ Object
Constructor Details
#initialize(group:, current_user:, shared:, params: {}) ⇒ TreeSaver
Returns a new instance of TreeSaver.
9 10 11 12 13 14 15 |
# File 'lib/gitlab/import_export/group/tree_saver.rb', line 9 def initialize(group:, current_user:, shared:, params: {}) @params = params @current_user = current_user @shared = shared @group = group @full_path = File.join(@shared.export_path, 'tree') end |
Instance Attribute Details
#full_path ⇒ Object (readonly)
Returns the value of attribute full_path.
7 8 9 |
# File 'lib/gitlab/import_export/group/tree_saver.rb', line 7 def full_path @full_path end |
#shared ⇒ Object (readonly)
Returns the value of attribute shared.
7 8 9 |
# File 'lib/gitlab/import_export/group/tree_saver.rb', line 7 def shared @shared end |
Instance Method Details
#save ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/import_export/group/tree_saver.rb', line 17 def save all_groups = Enumerator.new do |group_ids| groups.each do |group| serialize(group) group_ids << group.id end end json_writer.write_relation_array('groups', '_all', all_groups) true rescue StandardError => e @shared.error(e) false ensure json_writer&.close end |