Class: DataMapper::Property::CommaSeparatedList

Inherits:
Yaml
  • Object
show all
Defined in:
lib/dm-types/comma_separated_list.rb

Instance Method Summary collapse

Methods inherited from Yaml

#custom?, #load, #typecast

Methods included from DirtyMinder

#set!

Instance Method Details

#dump(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dm-types/comma_separated_list.rb', line 8

def dump(value)
  if value.nil?
    nil
  elsif value.kind_of?(::Array)
    super(value)
  elsif value.kind_of?(::String)
    v = []

    value.split(',').each do |element|
      element.strip!
      v << element unless element.empty?
    end

    super(v)
  else
    raise ArgumentError, "+value+ of CommaSeparatedList must be a string, an array or nil, but given #{value.inspect}"
  end
end