Class: DataMapper::Types::Slug

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

Class Method Summary collapse

Class Method Details

.dump(value, property) ⇒ Object



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

def self.dump(value, property)
  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

.escape(string) ⇒ Object



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

def self.escape(string)
  string.to_url
end

.load(value, property) ⇒ Object



9
10
11
# File 'lib/dm-types/slug.rb', line 9

def self.load(value, property)
  value
end