Class: Importable::Importer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Importable::Importer
show all
- Includes:
- MultiStep::ImportHelpers
- Defined in:
- app/models/importable/importer.rb
Instance Attribute Summary collapse
#current_step
Instance Method Summary
collapse
#first_step?, #last_step?, #next_step, #previous_step, #steps
Instance Attribute Details
#import_params ⇒ Object
15
16
17
|
# File 'app/models/importable/importer.rb', line 15
def import_params
@import_params || {}
end
|
Instance Method Details
#import! ⇒ Object
10
11
12
13
|
# File 'app/models/importable/importer.rb', line 10
def import!
mapper.valid?
end
|
#imported_items_ready? ⇒ Boolean
43
44
45
|
# File 'app/models/importable/importer.rb', line 43
def imported_items_ready?
true
end
|
#invalid_items ⇒ Object
23
24
25
|
# File 'app/models/importable/importer.rb', line 23
def invalid_items
mapper.invalid_items
end
|
#mapper ⇒ Object
19
20
21
|
# File 'app/models/importable/importer.rb', line 19
def mapper
@mapper ||= mapper_class.new(rows, import_params)
end
|
#mapper_class ⇒ Object
27
28
29
|
# File 'app/models/importable/importer.rb', line 27
def mapper_class
singular_mapper_class || plural_mapper_class
end
|
#mapper_name_with_module ⇒ Object
39
40
41
|
# File 'app/models/importable/importer.rb', line 39
def mapper_name_with_module
mapper_name.sub('-', '/')
end
|
#plural_mapper_class ⇒ Object
35
36
37
|
# File 'app/models/importable/importer.rb', line 35
def plural_mapper_class
"#{mapper_name_with_module.pluralize}_mapper".camelize.constantize rescue nil
end
|
#singular_mapper_class ⇒ Object
31
32
33
|
# File 'app/models/importable/importer.rb', line 31
def singular_mapper_class
"#{mapper_name_with_module.singularize}_mapper".camelize.constantize rescue nil
end
|