- Defined in:
Adapter for MongoMapper models
class Product include MongoMapper::Document include end Product.import(path_to_xml_or_csv_file)
It sends the given file to a parser and then imports detected objects. Instead of simply inserting all detected objects to database, the importer tries to determine wheter a detected object already exists. If so, the object is only updated, otherwise a new object is created.
To change the way how importer checks for existing objects (or to turn off this behavior completely) override
find_on_import method. The default behavior now is to try to find existing object by detected object's id.
By default the detected object's attributes hash is literally assigned to a soon-to-be-saved object. If there is a need for more sophisticated behavior, simply override
Defined Under Namespace
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
29 30 31 32
# File 'lib/importer/adapters/mongo_mapper_adapter.rb', line 29 def included(base) base.send(:include, ) base.send(:extend, ) end