Module: Forgeos::Urlified

Defined in:
lib/forgeos/urlified.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/forgeos/urlified.rb', line 3

def self.included(base)
  base.before_validation :force_url_format, :generate_url
end

Instance Method Details

#force_url_formatObject



7
8
9
# File 'lib/forgeos/urlified.rb', line 7

def force_url_format
  self.url= Forgeos::url_generator(self.url)
end

#generate_urlObject



11
12
13
14
# File 'lib/forgeos/urlified.rb', line 11

def generate_url
  return true if self.url.present?
  self.url = self.name.parameterize if self.name.present?
end