Module: Importer::Adapters::DataMapperAdapter
- Defined in:
- lib/importer/adapters/data_mapper_adapter.rb
Overview
Adapter for DataMapper models
Usage:
class Product
include DataMapper::Resource
include Importer
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 merge_attributes_on_import
method.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
29 30 31 32 |
# File 'lib/importer/adapters/data_mapper_adapter.rb', line 29 def included(base) base.send(:include, InstanceMethods) base.send(:extend, ClassMethods) end |