Class: Gitlab::ImportExport::FastHashSerializer

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

Defined Under Namespace

Classes: JSONBatchRelation

Constant Summary collapse

BATCH_SIZE =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, tree, batch_size: BATCH_SIZE) ⇒ FastHashSerializer

Returns a new instance of FastHashSerializer.



76
77
78
79
80
# File 'lib/gitlab/import_export/fast_hash_serializer.rb', line 76

def initialize(subject, tree, batch_size: BATCH_SIZE)
  @subject = subject
  @batch_size = batch_size
  @tree = tree
end

Instance Attribute Details

#subjectObject (readonly)

Returns the value of attribute subject.



27
28
29
# File 'lib/gitlab/import_export/fast_hash_serializer.rb', line 27

def subject
  @subject
end

#treeObject (readonly)

Returns the value of attribute tree.



27
28
29
# File 'lib/gitlab/import_export/fast_hash_serializer.rb', line 27

def tree
  @tree
end

Instance Method Details

#executeObject

With the usage of ‘JSONBatchRelation`, it returns partially serialized hash which is not easily accessible. It means you can only manipulate and replace top-level objects. All future mutations of the hash (such as `fix_project_tree`) should be aware of that.



87
88
89
# File 'lib/gitlab/import_export/fast_hash_serializer.rb', line 87

def execute
  simple_serialize.merge(serialize_includes)
end