Class: DataMapper::Property::Csv

Inherits:
String
  • Object
show all
Includes:
DirtyMinder
Defined in:
lib/dm-types/csv.rb

Instance Method Summary collapse

Methods included from DirtyMinder

#set!

Instance Method Details

#dump(value) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/dm-types/csv.rb', line 23

def dump(value)
  case value
  when ::Array
    CSV.generate { |csv| value.each { |row| csv << row } }
  when ::String then value
  end
end

#load(value) ⇒ Object



16
17
18
19
20
21
# File 'lib/dm-types/csv.rb', line 16

def load(value)
  case value
  when ::String then CSV.parse(value)
  when ::Array  then value
  end
end