Class: DataMapper::Types::FilePath

Inherits:
DataMapper::Type show all
Defined in:
lib/gems/dm-types-0.9.9/lib/dm-types/file_path.rb

Constant Summary

Constants inherited from DataMapper::Type

DataMapper::Type::PROPERTY_OPTIONS, DataMapper::Type::PROPERTY_OPTION_ALIASES

Class Method Summary collapse

Methods inherited from DataMapper::Type

bind, configure, inherited, options, primitive

Class Method Details

.dump(value, property) ⇒ Object



16
17
18
19
# File 'lib/gems/dm-types-0.9.9/lib/dm-types/file_path.rb', line 16

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

.load(value, property) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/gems/dm-types-0.9.9/lib/dm-types/file_path.rb', line 8

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

.typecast(value, property) ⇒ Object



21
22
23
24
# File 'lib/gems/dm-types-0.9.9/lib/dm-types/file_path.rb', line 21

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