Sha256: 055119f64e98755386dc35ea7c00118cf22d71c5af8a10f59d90900a22725f82
Contents?: true
Size: 672 Bytes
Versions: 3
Compression:
Stored size: 672 Bytes
Contents
require 'dm-serializer/common' begin gem('fastercsv') require 'faster_csv' rescue LoadError nil end module DataMapper module Serialize # Serialize a Resource to comma-separated values (CSV). # # @return <String> a CSV representation of the Resource def to_csv(writer = '') FasterCSV.generate(writer) do |csv| row = [] self.class.properties(repository.name).each do |property| row << send(property.name).to_s end csv << row end end end class Collection def to_csv result = "" each do |item| result << item.to_csv + "\n" end result end end end
Version data entries
3 entries across 3 versions & 2 rubygems