Skip to content

Commit

Permalink
Clean up generate_handle implementation and attempt to transliterate.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreisner committed Sep 3, 2009
1 parent 8cc0eaf commit 3bd157d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def self.included(base)
base.extend ClassMethods
end


module ClassMethods

##
Expand All @@ -25,15 +24,16 @@ def handle_based_on(attribute, options = {})
# Generate a URL-friendly name.
#
define_method :generate_handle do
str = send(attribute)
return nil unless str.is_a?(String)
returning send(attribute) do |str|
str.downcase!
str.strip!
str.gsub!('&', ' and ') # add space for, e.g., "Y&T"
str.delete!('.\'"') # no space
str.gsub!(/\W/, ' ') # space
str.gsub!(/ +/, options[:separator])
end
#str = ActiveSupport::Inflector.transliterate(str).to_s
str = str.downcase
str = str.strip
str = str.gsub('&', ' and ') # add space for, e.g., "Y&T"
str = str.delete('.\'"') # no space
str = str.gsub(/\W/, ' ') # space
str = str.gsub(/ +/, options[:separator])
str
end

##
Expand Down

0 comments on commit 3bd157d

Please sign in to comment.