Class: Importer::Import
- Inherits:
-
Object
- Object
- Importer::Import
- Defined in:
- lib/importer/import.rb
Overview
Summary of import. Contains detailed information about import process, all imported objects, no matter if they were imported successfully or not.
The importer builds it’s Import instance by adding imported objects via add_object
.
If you want to have your own implementation of Import summary (f.e. activerecord-based), you can force the importer to use it with:
Product.import(path_to_xml_or_csv_file, :import => CustomImportClass)
Just be sure to implement add_object
and build_imported_object
methods in your custom class.
Instance Attribute Summary collapse
-
#imported_objects ⇒ Object
readonly
Returns the value of attribute imported_objects.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #add_object(imported_object) ⇒ Object
- #build_imported_object ⇒ Object
- #existing_imported_objects ⇒ Object
-
#initialize(options = nil) ⇒ Import
constructor
A new instance of Import.
- #invalid_imported_objects ⇒ Object
- #new_imported_objects ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Import
Returns a new instance of Import.
19 20 21 22 |
# File 'lib/importer/import.rb', line 19 def initialize( = nil) @imported_objects = [] @options = end |
Instance Attribute Details
#imported_objects ⇒ Object (readonly)
Returns the value of attribute imported_objects.
17 18 19 |
# File 'lib/importer/import.rb', line 17 def imported_objects @imported_objects end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/importer/import.rb', line 17 def @options end |
Instance Method Details
#add_object(imported_object) ⇒ Object
24 25 26 |
# File 'lib/importer/import.rb', line 24 def add_object(imported_object) imported_objects << imported_object end |
#build_imported_object ⇒ Object
28 29 30 |
# File 'lib/importer/import.rb', line 28 def build_imported_object ImportedObject.new end |
#existing_imported_objects ⇒ Object
36 37 38 |
# File 'lib/importer/import.rb', line 36 def existing_imported_objects imported_objects.select { |object| object.state == 'existing_object' } end |
#invalid_imported_objects ⇒ Object
40 41 42 |
# File 'lib/importer/import.rb', line 40 def invalid_imported_objects imported_objects.select { |object| object.state == 'invalid_object' } end |
#new_imported_objects ⇒ Object
32 33 34 |
# File 'lib/importer/import.rb', line 32 def new_imported_objects imported_objects.select { |object| object.state == 'new_object' } end |