Sha256: c03454d5354d8f70878b19ed467642d76de86a3d0ab2290b778adcd137c6953d
Contents?: true
Size: 825 Bytes
Versions: 28
Compression:
Stored size: 825 Bytes
Contents
module Integrity class Author < DataMapper::Type primitive String size 65535 lazy true class AuthorStruct < Struct.new(:name, :email) def self.parse(string) raise ArgumentError.new("invalid author string") unless string =~ /^(.*) <(.*)>$/ new($1.strip, $2.strip) end def to_s @full ||= "#{name} <#{email}>" end alias_method :full, :to_s end def self.load(value, property) AuthorStruct.parse(value) unless value.nil? end def self.dump(value, property) return nil if value.nil? value.to_s end def self.typecast(value, property) case value when AuthorStruct then value when NilClass then load(nil, property) else load(value.to_s, property) end end end end
Version data entries
28 entries across 28 versions & 8 rubygems