Sha256: ccbba07151a5caccba7ad565d01ea6b4c7c1232a442beeaab701656423d19bae
Contents?: true
Size: 872 Bytes
Versions: 3
Compression:
Stored size: 872 Bytes
Contents
module DataMapper module Types class CommaSeparatedList < Yaml # this must be set even though Yaml already # uses String primitive # # current DM::Type behavior probably needs to # be improved for cases like this primitive String def self.dump(value, property) if value.nil? nil elsif value.kind_of?(Array) super(value, property) elsif value.kind_of?(String) v = (value || "").split(","). compact. map { |i| i.downcase.strip }. reject { |i| i.blank? }. uniq super(v, property) else raise ArgumentError, "+value+ of CommaSeparatedList must be a string, an array or nil, but given #{value.inspect}" end end # self.dump end # CommaSeparatedList end # Types end # DataMapper
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dm-types-0.10.2 | lib/dm-types/comma_separated_list.rb |
dm-types-0.10.1 | lib/dm-types/comma_separated_list.rb |
dm-types-0.10.0 | lib/dm-types/comma_separated_list.rb |