Module: Sluggy::ClassMethods

Defined in:
lib/sluggy.rb

Instance Method Summary collapse

Instance Method Details

#slug_for(base, options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/sluggy.rb', line 9

def slug_for(base, options={})
  options.reverse_merge!(:column => :permalink, :base => base, :scope => nil)
  validates options[:column], :presence => true, :format => { :with => Sluggy::SLUG_REGEX }, :length => { :within => 1..100 }, :uniqueness => (options[:scope] ? {:scope => options[:scope]} : true)
  before_validation :generate_slug
  class_eval %{ def self.sluggy_options; #{options}; end }
  include Sluggy::InstanceMethods
end