Class: DataShift::ExcelLoader

Inherits:
LoaderBase show all
Includes:
ExcelLoading
Defined in:
lib/loaders/excel_loader.rb

Instance Attribute Summary

Attributes included from ExcelLoading

#contains_data, #excel

Attributes included from ExcelBase

#excel_headers, #header_row_index

Attributes inherited from LoaderBase

#config, #current_row_idx, #headers, #load_object, #load_object_class, #method_mapper, #populator, #reporter, #verbose

Instance Method Summary collapse

Methods included from ExcelLoading

#perform_excel_load, #process_excel_failure, #process_excel_row, #start_excel, #value_at

Methods included from ExcelBase

#ar_to_headers, #ar_to_xls, #ar_to_xls_cell, #ar_to_xls_row, #parse_headers, #sanitize_sheet_name

Methods inherited from LoaderBase

#abort_on_failure?, #configure_from, #failed_count, #failure, #find_and_process, #find_or_new, #get_operator_and_data, #headers_contain_mandatory?, #loaded_count, #missing_mandatory_headers, #new_load_object, #options, #populate_method_mapper_from_headers, #process, #process_defaults, #report, #reset, #save, #save_and_report

Methods included from Querying

#get_record_by, #get_record_by!, #search_for_record

Methods included from Logging

#logdir, #logger

Constructor Details

#initialize(klass, object = nil, options = {}) ⇒ ExcelLoader

Setup loading

Options to drive building the method dictionary for a class, enabling headers to be mapped to operators on that class.

Options :reload : Force load of the method dictionary for object_class even if already loaded :instance_methods : Include setter/delegate style instance methods for assignment, as well as AR columns :verbose : Verbose logging and to STDOUT



208
209
210
211
# File 'lib/loaders/excel_loader.rb', line 208

def initialize(klass, object = nil, options = {})
  super( klass, object, options )
  raise "Cannot load - failed to create a #{klass}" unless @load_object
end

Instance Method Details

#perform_load(file_name, options = {}) ⇒ Object



214
215
216
217
218
219
220
221
# File 'lib/loaders/excel_loader.rb', line 214

def perform_load( file_name, options = {} )

  logger.info "Starting bulk load from Excel : #{file_name}"

  perform_excel_load( file_name, options )

  puts "Excel loading stage complete - #{loaded_count} rows added."
end