class SeedGimmick::SeedIO::YamlFile

Public Class Methods

data_key(id) click to toggle source
# File lib/seed_gimmick/seed_io/yaml_file.rb, line 13
def data_key(id)
  "data%d" % id
end
raw_data(array_of_hashes) click to toggle source
# File lib/seed_gimmick/seed_io/yaml_file.rb, line 5
def raw_data(array_of_hashes)
  data = {}
  array_of_hashes.each.with_index(1) do |row, i|
    data[data_key(i)] = row
  end
  data.to_yaml
end

Public Instance Methods

dump_data(array_of_hashes) click to toggle source
# File lib/seed_gimmick/seed_io/yaml_file.rb, line 24
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/yaml_file.rb, line 18
def load_data
  data = YAML.load_file(seed_file) || (raise LoadFailed.new(seed_file))
  set_data(data.values)
  self
end