Class: DataMapper::Property::FilePath

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

Instance Method Summary collapse

Instance Method Details

#dump(value) ⇒ Object



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

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

#load(value) ⇒ Object



18
19
20
# File 'lib/dm-types/file_path.rb', line 18

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

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/dm-types/file_path.rb', line 10

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

#typecast_to_primitive(value) ⇒ Object



26
27
28
# File 'lib/dm-types/file_path.rb', line 26

def typecast_to_primitive(value)
  load(value)
end

#valid?(value, negated = false) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dm-types/file_path.rb', line 14

def valid?(value, negated = false)
  super || dump(value).kind_of?(::String)
end