Sha256: 2e3bc66145df74467a78d82fc5bd79006703db29d7f254edff4dc6219822f612

Contents?: true

Size: 545 Bytes

Versions: 2

Compression:

Stored size: 545 Bytes

Contents

require 'pathname'
require 'dm-core'

module DataMapper
  class Property
    class FilePath < String
      length 255

      def primitive?(value)
        value.kind_of?(Pathname)
      end

      def load(value)
        if value.blank?
          nil
        else
          Pathname.new(value)
        end
      end

      def dump(value)
        return nil if value.blank?
        value.to_s
      end

      def typecast_to_primitive(value)
        load(value)
      end
    end # class FilePath
  end # class Property
end # module DataMapper

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-types-1.0.0.rc2 lib/dm-types/file_path.rb
dm-types-1.0.0.rc1 lib/dm-types/file_path.rb