class SourceFile::<%= class_name %> < SourceFile
  def load_source_records
    <%- if attributes.present? -%>
    assert_first_line "<%= attributes.map(&:name).join(CsvBuilder.default_csv_options[:col_sep] || ',') %>"
    <%- end -%>
    <%- if options.source_record -%>
    SourceRecord::<%= class_name %>.truncate
    <%- end -%>
    <%- if options.sql -%>

    execute_sql_erb_script(:load_<%= file_name %>)
    execute_sql_erb_script(:post_process_<%= file_name %>)
    <%- end -%>
    <%- if options.source_record -%>

    self.number_of_records = SourceRecord::<%= class_name %>.count
    <%- end -%>
  end

<%- if has_workflow? -%>
  def after_activate_hook
    # call app/models/workflow_instance/data_setup create_or_update method
    WorkflowInstance.create_or_update_from_<%= file_name %>
  end
<%- end -%>
end
