Sha256: 77b31126f46a1f3b25ec532ea27796502083ce4c5f35270a94e4c7cbc8b2eac8
Contents?: true
Size: 779 Bytes
Versions: 1
Compression:
Stored size: 779 Bytes
Contents
require 'yaml' module DataMapper module Types class Yaml < DataMapper::Type primitive Text def self.load(value, property) if value.nil? nil elsif value.is_a?(String) ::YAML.load(value) else raise ArgumentError.new("+value+ of a property of YAML type must be nil or a String") end end def self.dump(value, property) if value.nil? nil elsif value.is_a?(String) && value =~ /^---/ value else ::YAML.dump(value) end end def self.typecast(value, property) # No typecasting; leave values exactly as they're provided. value end end # class Yaml end # module Types end # module DataMapper
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dm-types-0.10.2 | lib/dm-types/yaml.rb |