Sha256: 46cc942a0a8bcb60fb13e2c6a9d24d7beabad1e67d41cf5775b36cd9b0691df2

Contents?: true

Size: 484 Bytes

Versions: 1

Compression:

Stored size: 484 Bytes

Contents

module SeedGimmick
  module SeedIO
    class YamlFile < Base
      def load_data
        data = YAML.load_file(seed_file) || (raise LoadFailed.new(seed_file))
        data.values
      end

      def dump_data(array_of_hashes)
        data = {}
        array_of_hashes.each.with_index(1) do |row, i|
          data[data_key(i)] = row
        end

        write_raw(data.to_yaml)
      end

      private
        def data_key(id)
          "data%d" % id
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seed_gimmick-0.0.2 lib/seed_gimmick/seed_io/yaml_file.rb