class SeedGimmick::SeedIO::CsvFile
Public Class Methods
raw_data(array_of_hashes)
click to toggle source
# File lib/seed_gimmick/seed_io/csv_file.rb, line 4 def self.raw_data(array_of_hashes) columns = array_of_hashes.first.keys array_of_hashes.map(&:values).unshift(columns).map(&:to_csv).join end
Public Instance Methods
dump_data(array_of_hashes)
click to toggle source
# File lib/seed_gimmick/seed_io/csv_file.rb, line 16 def dump_data(array_of_hashes) write_raw(self.class.raw_data(array_of_hashes)) array_of_hashes.size end
load_data()
click to toggle source
# File lib/seed_gimmick/seed_io/csv_file.rb, line 9 def load_data data = CSV.read(seed_file, headers: :first_row).map(&:to_hash) || (raise LoadFailed.new(seed_file)) set_data(data) self end