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



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

def escape(string)
  string.to_url
end

#typecast(value) ⇒ Object



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

def typecast(value)
  return if value.nil?

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