Sha256: 176fe237df57885a184f82867c21fc9575ffbe2a1f252c691b1f819eefd6dc09

Contents?: true

Size: 588 Bytes

Versions: 12

Compression:

Stored size: 588 Bytes

Contents

require 'pathname'

module DataMapper
  module Types
    class FilePath < DataMapper::Type
      primitive String

      def self.load(value, property)
        if value.nil?
          nil
        else
          Pathname.new(value)
        end
      end

      def self.dump(value, property)
        return nil if value.nil?
        value.to_s
      end

      def self.typecast(value, property)
        # Leave alone if a Pathname is given.
        value.kind_of?(Pathname) ? value : load(value, property)
      end
    end # class FilePath
  end # module Types
end # module DataMapper

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
dm-types-0.9.4 lib/dm-types/file_path.rb
dm-types-0.9.10 lib/dm-types/file_path.rb
dm-types-0.9.11 lib/dm-types/file_path.rb
dm-types-0.9.5 lib/dm-types/file_path.rb
dm-types-0.9.3 lib/dm-types/file_path.rb
dm-types-0.9.6 lib/dm-types/file_path.rb
dm-types-0.9.8 lib/dm-types/file_path.rb
dm-types-0.9.7 lib/dm-types/file_path.rb
dm-types-0.9.9 lib/dm-types/file_path.rb
mack-data_mapper-0.8.2 lib/gems/dm-types-0.9.7/lib/dm-types/file_path.rb
mack-data_mapper-0.8.3 lib/gems/dm-types-0.9.9/lib/dm-types/file_path.rb
mack-data_mapper-0.8.3.1 lib/gems/dm-types-0.9.9/lib/dm-types/file_path.rb