module Hydroponics module Actions def dupe(table, target_count) table = table.to_sym first_row = @db[table].first first_row.delete(:id) current_count = @db[table].count if target_count > current_count @db[table].multi_insert([first_row] * (target_count - current_count)) elsif current_count > target_count cutoff_id = @db[table].map(:id)[target_count-1] @db[table].filter("id > #{cutoff_id}").delete end @db[table].count.to_s end end end