Sha256: 6af9b9c7854b00f57c40228d56612c52b4755df878c518f640976c4d6a8ce872

Contents?: true

Size: 621 Bytes

Versions: 9

Compression:

Stored size: 621 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 valid?(value, negated = false)
        super || dump(value).kind_of?(::String)
      end

      def load(value)
        Pathname.new(value) unless DataMapper::Ext.blank?(value)
      end

      def dump(value)
        value.to_s unless DataMapper::Ext.blank?(value)
      end

      def typecast_to_primitive(value)
        load(value)
      end

    end # class FilePath
  end # class Property
end # module DataMapper

Version data entries

9 entries across 9 versions & 2 rubygems

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