Commit 9c639041 authored by James Lopez's avatar James Lopez

bit more refactoring of import export reader, fixed rubocop warning

parent 3aee167d
...@@ -32,4 +32,4 @@ module Gitlab ...@@ -32,4 +32,4 @@ module Gitlab
end end
end end
end end
end end
\ No newline at end of file
...@@ -17,30 +17,30 @@ module Gitlab ...@@ -17,30 +17,30 @@ module Gitlab
private private
def build_hash(model_list) def build_hash(model_list)
model_list.map do |model_object| model_list.map do |model_object_hash|
if model_object.is_a?(Hash) if model_object_hash.is_a?(Hash)
process_include(model_object) process_model_object(model_object_hash)
else else
@attributes_parser.find(model_object) @attributes_parser.find(model_object_hash)
end end
end end
end end
def process_include(hash, included_classes_hash = {}) def process_model_object(model_object_hash, included_classes_hash = {})
hash.values.flatten.each do |value| model_object_hash.values.flatten.each do |model_object|
current_key = hash.keys.first current_key = model_object_hash.keys.first
value = process_current_class(hash, included_classes_hash, value) model_object = process_current_class(model_object_hash, included_classes_hash, model_object)
if included_classes_hash[current_key] if included_classes_hash[current_key]
add_to_class(current_key, included_classes_hash, value) add_to_class(current_key, included_classes_hash, model_object)
else else
add_new_class(current_key, included_classes_hash, value) add_new_class(current_key, included_classes_hash, model_object)
end end
end end
included_classes_hash included_classes_hash
end end
def process_current_class(hash, included_classes_hash, value) def process_current_class(hash, included_classes_hash, value)
value = value.is_a?(Hash) ? process_include(hash, included_classes_hash) : value value = value.is_a?(Hash) ? process_model_object(hash, included_classes_hash) : value
attributes_hash = @attributes_parser.find_attributes_only(hash.keys.first) attributes_hash = @attributes_parser.find_attributes_only(hash.keys.first)
included_classes_hash[hash.keys.first] ||= attributes_hash unless attributes_hash.empty? included_classes_hash[hash.keys.first] ||= attributes_hash unless attributes_hash.empty?
value value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment