Class: Importable::Importer

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
MultiStep::ImportHelpers
Defined in:
app/models/importable/importer.rb

Direct Known Subclasses

Resource, Spreadsheet

Instance Attribute Summary collapse

Attributes included from MultiStep::ImportHelpers

#current_step

Instance Method Summary collapse

Methods included from MultiStep::ImportHelpers

#first_step?, #last_step?, #next_step, #previous_step, #steps

Instance Attribute Details

#import_paramsObject



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!
  #TODO: help
  mapper.valid?
end

#imported_items_ready?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/models/importable/importer.rb', line 43

def imported_items_ready?
  true
end

#invalid_itemsObject



23
24
25
# File 'app/models/importable/importer.rb', line 23

def invalid_items
  mapper.invalid_items
end

#mapperObject



19
20
21
# File 'app/models/importable/importer.rb', line 19

def mapper
  @mapper ||= mapper_class.new(rows, import_params)
end

#mapper_classObject



27
28
29
# File 'app/models/importable/importer.rb', line 27

def mapper_class
  singular_mapper_class || plural_mapper_class
end

#mapper_name_with_moduleObject



39
40
41
# File 'app/models/importable/importer.rb', line 39

def mapper_name_with_module
  mapper_name.sub('-', '/')
end

#plural_mapper_classObject



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_classObject



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