Added splat args to every method call in import factories.
This commit is contained in:
parent
81bfeac091
commit
2b2ceeebab
9 changed files with 22 additions and 22 deletions
|
@ -5,39 +5,39 @@ module Import
|
|||
extend self
|
||||
|
||||
def import_action(records, *args)
|
||||
pre_import_hook(records)
|
||||
import_loop(records) do |record|
|
||||
next if skip?(record)
|
||||
pre_import_hook(records, *args)
|
||||
import_loop(records, *args) do |record|
|
||||
next if skip?(record, *args)
|
||||
backend_instance = create_instance(record, *args)
|
||||
post_import_hook(record, backend_instance)
|
||||
post_import_hook(record, backend_instance, *args)
|
||||
end
|
||||
end
|
||||
|
||||
def import(_records)
|
||||
def import(_records, *_args)
|
||||
raise 'Missing import method implementation for this factory'
|
||||
end
|
||||
|
||||
def pre_import_hook(_records)
|
||||
def pre_import_hook(_records, *args)
|
||||
end
|
||||
|
||||
def post_import_hook(_record, _backend_instance)
|
||||
def post_import_hook(_record, _backend_instance, *args)
|
||||
end
|
||||
|
||||
def backend_class(_record)
|
||||
def backend_class(_record, *_args)
|
||||
"Import::#{module_name}".constantize
|
||||
end
|
||||
|
||||
def skip?(_record)
|
||||
def skip?(_record, *_args)
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_instance(record, *args)
|
||||
backend_class(record).new(record, *args)
|
||||
backend_class(record, *args).new(record, *args)
|
||||
end
|
||||
|
||||
def import_loop(records, &import_block)
|
||||
def import_loop(records, *_args, &import_block)
|
||||
records.each(&import_block)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ module Import
|
|||
module ArticleCustomerFactory
|
||||
extend Import::Factory
|
||||
|
||||
def skip?(record)
|
||||
def skip?(record, *_args)
|
||||
return true if record['SenderType'] != 'customer'
|
||||
return true if record['CreatedBy'].to_i != 1
|
||||
return true if record['From'].empty?
|
||||
|
|
|
@ -7,13 +7,13 @@ module Import
|
|||
# rubocop:disable Style/ModuleFunction
|
||||
extend self
|
||||
|
||||
def skip?(record)
|
||||
def skip?(record, *_args)
|
||||
return true if !importable?(record)
|
||||
return true if skip_field?(record['Name'])
|
||||
false
|
||||
end
|
||||
|
||||
def backend_class(record)
|
||||
def backend_class(record, *_args)
|
||||
"Import::OTRS::DynamicField::#{record['FieldType']}".constantize
|
||||
end
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ module Import
|
|||
# rubocop:disable Style/ModuleFunction
|
||||
extend self
|
||||
|
||||
def skip?(record)
|
||||
def skip?(record, *_args)
|
||||
return true if !determine_class(record)
|
||||
false
|
||||
end
|
||||
|
||||
def backend_class(record)
|
||||
def backend_class(record, *_args)
|
||||
"Import::OTRS::History::#{determine_class(record)}".constantize
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ module Import
|
|||
# rubocop:disable Style/ModuleFunction
|
||||
extend self
|
||||
|
||||
def pre_import_hook(_records)
|
||||
def pre_import_hook(_records, *_args)
|
||||
backup
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Import
|
|||
# rubocop:disable Style/ModuleFunction
|
||||
extend self
|
||||
|
||||
def import(settings)
|
||||
def import(settings, *_args)
|
||||
settings.each do |setting|
|
||||
next if direct_copy?(setting)
|
||||
next if number_generator?(setting)
|
||||
|
|
|
@ -5,9 +5,9 @@ module Import
|
|||
# rubocop:disable Style/ModuleFunction
|
||||
extend self
|
||||
|
||||
def import(records)
|
||||
def import(records, *args)
|
||||
ActiveRecord::Base.transaction do
|
||||
import_action(records)
|
||||
import_action(records, *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Import
|
|||
|
||||
private
|
||||
|
||||
def import_loop(records, &import_block)
|
||||
def import_loop(records, *_args, &import_block)
|
||||
records.all!(&import_block)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module Import
|
|||
# rubocop:disable Style/ModuleFunction
|
||||
extend self
|
||||
|
||||
def skip?(field)
|
||||
def skip?(field, *_args)
|
||||
# check if the Ticket object already has a same named column / attribute
|
||||
# so we want to skip instead of importing it
|
||||
Ticket.column_names.include?( local_attribute(field) )
|
||||
|
|
Loading…
Reference in a new issue