Module: Acts::Importable::InstanceMethods

Defined in:
lib/acts_as_importable.rb

Overview

SingletonMethods

Instance Method Summary collapse

Instance Method Details

#importObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/acts_as_importable.rb', line 59

def import
  returning to_model do |new_model|
    if new_model
      new_model.legacy_id     = self.id         if new_model.respond_to?(:"legacy_id=")
      new_model.legacy_class  = self.class.to_s if new_model.respond_to?(:"legacy_class=")

      if !new_model.save
        p new_model.errors
        # TODO log an error that the model failed to save
        # TODO remove the raise once we're out of the development cycle
        raise
      else
        after_import(new_model) if self.respond_to? :after_import
      end
    end
  end
end