Class: DataMapper::Types::URI

Inherits:
DataMapper::Type show all
Defined in:
lib/gems/dm-types-0.9.7/lib/dm-types/uri.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



13
14
15
16
# File 'lib/gems/dm-types-0.9.7/lib/dm-types/uri.rb', line 13

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

.load(value, property) ⇒ Object



9
10
11
# File 'lib/gems/dm-types-0.9.7/lib/dm-types/uri.rb', line 9

def self.load(value, property)
  Addressable::URI.parse(value)
end

.typecast(value, property) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/gems/dm-types-0.9.7/lib/dm-types/uri.rb', line 18

def self.typecast(value, property)
  if value.kind_of?(Addressable::URI)
    value
  elsif value.nil?
    load(nil, property)
  else
    load(value.to_s, property)
  end
end