Module: LegacyMigrations::SourceIterators
- Defined in:
- lib/legacy_migrations/source_iterators.rb
Instance Method Summary collapse
Instance Method Details
#source_iterator(limit, type, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/legacy_migrations/source_iterators.rb', line 3 def source_iterator(limit, type, &block) if type == :active_record @from_table.all(limit) elsif type == :csv if limit[:limit] fewer_rows = [] rows_processed = 0 @from_table.each do |row| fewer_rows << row rows_processed += 1 break if rows_processed == limit[:limit].to_i end CSV::Table.new(fewer_rows) else @from_table end end end |