Class: Tire::Model::Import::Strategy::WillPaginate

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


99
100
101
102
103
104
105
106
107
108
109
# File 'lib/tire/model/import.rb', line 99

def import &block
  current = 0
  page = 1
  while current < klass.count
    items = klass.paginate(:page => page, :per_page => options[:per_page])
    index.import items, options, &block
    current += items.size
    page += 1
  end
  self
end