def import_file_data(file_path, content, import_type, strategy_name, additional_attributes = {}, options = {}) # probably file_path is a String and the result file_name as well file_name = File.basename(file_path) # no idea what tempfile is, a string? tempfile = write_to_temp_file(content, file_name) uploaded_file = OpenStruct.new(:original_filename => file_name, :tempfile => tempfile) # Is this now an instance of ResourceImport or a result of a resource import? resource_import = ResourceImport.import!(user, project, uploaded_file, file_path, import_type, strategy_name, additional_attributes) # Ok, nothing ambiguous here resource_uploader = ResourceUploader.new(resource_import) resource_uploader.store!(tempfile) if options.fetch(:schedule, true) ResourceImportsService.new.schedule_import(resource_import) else import_resource_import(resource_import) end # maybe reload already returns the resource_import new and we don't need the last line at all? resource_import.reload # implicit returns always felt 'dirty' to me. For example ActiveRecord callbacks which return false # break the chain, so you have to know that to not break it unintentionally resource_import.reload resource_import end