Class: Tire::Model::Import::Strategy::Mongoid

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/tire/model/import.rb

Instance Attribute Summary

Attributes included from Base

#index, #klass, #options

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#import(&block) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/tire/model/import.rb', line 68

def import &block
  items = []
  klass.all.each do |item|
    items << item
    if items.length % options[:per_page] == 0
      index.import items, options, &block
      items = []
    end
  end
  index.import items, options, &block unless items.empty?
  self
end