Module: Acts::Importable::SingletonMethods
- Defined in:
- lib/acts_as_importable.rb
Overview
ClassMethods
Instance Method Summary collapse
- #flush_lookups! ⇒ Object
- #import(id) ⇒ Object
- #import_all ⇒ Object
-
#import_all_in_batches ⇒ Object
This requires a numeric primary key for the legacy tables.
- #lookup(id) ⇒ Object
Instance Method Details
#flush_lookups! ⇒ Object
45 46 47 |
# File 'lib/acts_as_importable.rb', line 45 def flush_lookups! @lookups = {} end |
#import(id) ⇒ Object
23 24 25 |
# File 'lib/acts_as_importable.rb', line 23 def import(id) find(id).import end |
#import_all ⇒ Object
27 28 29 30 31 |
# File 'lib/acts_as_importable.rb', line 27 def import_all all.each do |legacy_model| legacy_model.import end end |
#import_all_in_batches ⇒ Object
This requires a numeric primary key for the legacy tables
34 35 36 37 38 |
# File 'lib/acts_as_importable.rb', line 34 def import_all_in_batches each do |legacy_model| legacy_model.import end end |
#lookup(id) ⇒ Object
40 41 42 43 |
# File 'lib/acts_as_importable.rb', line 40 def lookup(id) lookup_class = read_inheritable_attribute(:importable_to) || "#{self.to_s.split('::').last}" lookups[id] ||= Kernel.const_get(lookup_class).first(:conditions => {:legacy_id => id, :legacy_class => self.to_s}).try(:id__) end |