Class: ActImportManager

Inherits:
ImportManager show all
Defined in:
lib/import_manager/act_import_manager.rb

Overview

ActImportManager puts all creates and update actions that are part of the import under one act of a import card

Instance Attribute Summary

Attributes inherited from ImportManager

#conflict_strategy

Instance Method Summary collapse

Methods inherited from ImportManager

#add_extra_data, #extra_data, #handle_import, #import, #import_card, #import_rows

Methods included from ImportManager::Conflicts

#check_for_duplicates, #handle_conflict, #override?, #with_conflict_resolution, #with_conflict_strategy

Methods included from ImportManager::StatusLog

#error_list, #errors, #errors?, #errors_by_row_index, #import_status, #pick_up_card_errors, #report, #report_error

Constructor Details

#initialize(act_card, csv_file, conflict_strategy = :skip, extra_row_data = {}) ⇒ ActImportManager

Returns a new instance of ActImportManager.



4
5
6
7
# File 'lib/import_manager/act_import_manager.rb', line 4

def initialize act_card, csv_file, conflict_strategy=:skip, extra_row_data={}
  @act_card = act_card
  super(csv_file, conflict_strategy, extra_row_data)
end

Instance Method Details

#add_card(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/import_manager/act_import_manager.rb', line 9

def add_card args
  handle_conflict args[:name] do |existing_card|
    subcard =
      if existing_card
        existing_card.tap { |card| card.update_attributes args }
      else
        Card.create args
      end
    # subcard = @act_card&.add_subcard args.delete(:name), args
    # subcard.director.catch_up_to_stage :validate
    pick_up_card_errors { subcard }
  end
end

#duplicate(name) ⇒ Object



23
24
25
# File 'lib/import_manager/act_import_manager.rb', line 23

def duplicate name
  Card[name] || @act_card&.subcards&.at(name)
end

#log_statusObject



27
28
29
30
# File 'lib/import_manager/act_import_manager.rb', line 27

def log_status
  super
  @act_card&.import_status_card&.update_attributes content: @import_status.to_json
end