Class: DataMapper::Types::Csv

Inherits:
DataMapper::Type
  • Object
show all
Defined in:
lib/dm-types/csv.rb

Class Method Summary collapse

Class Method Details

.dump(value, property) ⇒ Object



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

def self.dump(value, property)
  case value
  when Array then
    FasterCSV.generate do |csv|
      value.each { |row| csv << row }
    end
  when String then value
  else nil
  end
end

.load(value, property) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/dm-types/csv.rb', line 8

def self.load(value, property)
  case value
  when String then FasterCSV.parse(value)
  when Array then value
  else nil
  end
end