Class: DataShift::ExcelLoader
- Inherits:
-
LoaderBase
- Object
- LoaderBase
- DataShift::ExcelLoader
- Includes:
- ExcelLoading
- Defined in:
- lib/loaders/excel_loader.rb
Instance Attribute Summary
Attributes included from ExcelLoading
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
-
#initialize(klass, object = nil, options = {}) ⇒ ExcelLoader
constructor
Setup loading.
- #perform_load(file_name, options = {}) ⇒ Object
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
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, = {}) super( klass, object, ) 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, = {} ) logger.info "Starting bulk load from Excel : #{file_name}" perform_excel_load( file_name, ) puts "Excel loading stage complete - #{loaded_count} rows added." end |