lib/active_support/inflector.rb in activesupport-2.0.2 vs lib/active_support/inflector.rb in activesupport-2.0.4

- old
+ new

@@ -160,11 +160,11 @@ # # Examples # "man from the boondocks".titleize #=> "Man From The Boondocks" # "x-men: the last stand".titleize #=> "X Men: The Last Stand" def titleize(word) - humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize } + humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize } end # The reverse of +camelize+. Makes an underscored form from the expression in the string. # # Changes '::' to '/' to convert namespaces to paths. @@ -216,16 +216,19 @@ # "fancyCategory".tableize #=> "fancy_categories" def tableize(class_name) pluralize(underscore(class_name)) end - # Create a class name from a table name like Rails does for table names to models. + # Create a class name from a plural table name like Rails does for table names to models. # Note that this returns a string and not a Class. (To convert to an actual class # follow classify with constantize.) # # Examples # "egg_and_hams".classify #=> "EggAndHam" - # "post".classify #=> "Post" + # "posts".classify #=> "Post" + # + # Singular names are not handled correctly + # "business".classify #=> "Busines" def classify(table_name) # strip out any leading schema name camelize(singularize(table_name.to_s.sub(/.*\./, ''))) end