Class: DataMapper::Property::Csv

Inherits:
Text
  • 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



26
27
28
29
30
31
32
# File 'lib/dm-types/csv.rb', line 26

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

#load(value) ⇒ Object



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

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

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/dm-types/csv.rb', line 15

def primitive?(value)
  super || value.kind_of?(::Array)
end