Class: DataMapper::Property::URI

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

Instance Method Summary collapse

Instance Method Details

#custom?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/dm-types/uri.rb', line 12

def custom?
  true
end

#dump(value) ⇒ Object



28
29
30
# File 'lib/dm-types/uri.rb', line 28

def dump(value)
  value.to_s unless value.nil?
end

#load(value) ⇒ Object



24
25
26
# File 'lib/dm-types/uri.rb', line 24

def load(value)
  Addressable::URI.parse(value)
end

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dm-types/uri.rb', line 16

def primitive?(value)
  value.kind_of?(Addressable::URI)
end

#typecast_to_primitive(value) ⇒ Object



32
33
34
# File 'lib/dm-types/uri.rb', line 32

def typecast_to_primitive(value)
  load(value)
end

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

Returns:

  • (Boolean)


20
21
22
# File 'lib/dm-types/uri.rb', line 20

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