class SourceFile::MySource < SourceFile
  def load_source_records
    assert_first_line "my_date,my_var,My count,my_num,my_truth"
    SourceRecord::MySource.truncate

    #execute_sql_erb_script(:load_my_source)
    #execute_sql_erb_script(:post_process_my_source)
    CSV.foreach working_file.path, headers: :first_row do |row|
      SourceRecord::MySource.create \
        my_date: row['my_date'],
        my_var: row['my_var'],
        my_count: row['My count'],
        my_num: row['my_num'],
        my_truth: row['my_truth']
    end

    self.number_of_records = SourceRecord::MySource.count
  end

  def after_activate_hook
    WorkflowInstance.create_or_update_from_my_source
  end
end
