Class: DataMapper::Property::Slug

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

Instance Method Summary collapse

Instance Method Details

#escape(string) ⇒ Object



23
24
25
# File 'lib/dm-types/slug.rb', line 23

def escape(string)
  string.to_url
end

#typecast(value) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/dm-types/slug.rb', line 13

def typecast(value)
  if value.nil?
    nil
  elsif value.respond_to?(:to_str)
    escape(value.to_str)
  else
    raise ArgumentError, '+value+ must be nil or respond to #to_str'
  end
end