Class: DataMapper::Types::FilePath

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

Class Method Summary collapse

Class Method Details

.dump(value, property) ⇒ Object



16
17
18
19
# File '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/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/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