class ActiveRecordImporter::Import
Attributes
execute_on_create[RW]
Public Instance Methods
batch_size()
click to toggle source
Calls superclass method
# File lib/app/models/import.rb, line 42 def batch_size super.to_i end
execute()
click to toggle source
I’ll add import options in the next major release accepts_nested_attributes_for :import_options, allow_destroy: true
# File lib/app/models/import.rb, line 30 def execute resource_class.import!(object: self, execute: execute_on_create) end
execute!()
click to toggle source
# File lib/app/models/import.rb, line 34 def execute! resource_class.import!(object: self, execute: true) end
failed_file_path()
click to toggle source
Override this method if you have private permissions or you have private methods for reading/writing uploaded files
# File lib/app/models/import.rb, line 60 def failed_file_path local_path?(failed_file) ? failed_file.path : failed_file.url end
import_file()
click to toggle source
Override this if you prefer have private permissions or you have private methods for reading files
# File lib/app/models/import.rb, line 51 def import_file local_path?(file) ? file.path : file.url end
resource_class()
click to toggle source
# File lib/app/models/import.rb, line 38 def resource_class resource.safe_constantize end
Private Instance Methods
check_presence_of_find_options()
click to toggle source
# File lib/app/models/import.rb, line 66 def check_presence_of_find_options return if insert_method.insert? errors.add(:find_options, "can't be blank") if find_options.blank? end
local_path?(f)
click to toggle source
# File lib/app/models/import.rb, line 71 def local_path?(f) File.exist? f.path end