lib/slugr.rb in slugr-1.0.0 vs lib/slugr.rb in slugr-1.1.0
- old
+ new
@@ -1,19 +1,16 @@
require "slugr/version"
+require "string"
module Slugr
def self.included(base)
base.extend(ClassMethods)
- def slug_for_string streng
- return streng.gsub(/('|’)/, '').mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').parameterize.to_s
- end
-
def set_slug
return if (streng = self.send(self.source).to_s).blank?
return if only_set_slug_if_empty && self.send(self.target).present?
- self.send("#{self.target.to_s}=", slug_for_string(streng))
+ self.send("#{self.target.to_s}=", streng.to_s.slug)
end
end
module ClassMethods
def slugify source, args={}