Sha256: 413485124faa51636548e5026126d9959ba3699e318585e1dfe2d68e878f7ec6

Contents?: true

Size: 675 Bytes

Versions: 9

Compression:

Stored size: 675 Bytes

Contents

require 'dm-core'
require 'dm-types/yaml'

module DataMapper
  class Property
    class CommaSeparatedList < Yaml

      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 # dump

    end # CommaSeparatedList
  end # Property
end # DataMapper

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ardm-types-1.2.3 lib/dm-types/comma_separated_list.rb
ardm-types-1.2.2 lib/dm-types/comma_separated_list.rb
dm-types-1.2.2 lib/dm-types/comma_separated_list.rb
dm-types-1.2.1 lib/dm-types/comma_separated_list.rb
dm-types-1.2.0 lib/dm-types/comma_separated_list.rb
dm-types-1.2.0.rc2 lib/dm-types/comma_separated_list.rb
dm-types-1.2.0.rc1 lib/dm-types/comma_separated_list.rb
dm-types-1.1.0 lib/dm-types/comma_separated_list.rb
dm-types-1.1.0.rc3 lib/dm-types/comma_separated_list.rb