lib/dm-serializer/to_csv.rb in dm-serializer-0.10.2 vs lib/dm-serializer/to_csv.rb in dm-serializer-1.0.0.rc1

- old
+ new

@@ -23,10 +23,27 @@ __send__(property.name).to_s end csv << row end end + + module ValidationErrors + module ToCsv + def to_csv(writer = '') + CSV.generate(writer) do |csv| + errors.each do |key, value| + value.each do |error| + row = [] + row << key.to_s + row << error.to_s + csv << row + end + end + end + end + end + end end class Collection def to_csv result = '' @@ -35,25 +52,14 @@ end result end end - if Serialize::Support.dm_validations_loaded? + if Serialize.dm_validations_loaded? - module Validate + module Validations class ValidationErrors - def to_csv(writer = '') - CSV.generate(writer) do |csv| - errors.each do |key, value| - value.each do |error| - row = [] - row << key.to_s - row << error.to_s - csv << row - end - end - end - end + include DataMapper::Serialize::ValidationErrors::ToCsv end end end