lib/core/facets/string/methodize.rb in facets-2.8.4 vs lib/core/facets/string/methodize.rb in facets-2.9.0.pre.1
- old
+ new
@@ -1,19 +1,20 @@
class String
# Translate a (class or module) name to a suitable method name.
#
- # My::CoolClass.name.methodize => "my__cool_class"
+ # "My::CoolClass".methodize #=> "my__cool_class"
#
#--
- # Rails definition:
+ # Rails definition ...
#
# gsub(/\//, '__').
# gsub(/::/, '__').
# gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
# gsub(/([a-z\d])([A-Z])/,'\1_\2').
# tr("-", "_").
# downcase
+ #
#++
def methodize
gsub(/([A-Z]+)([A-Z])/,'\1_\2').
gsub(/([a-z])([A-Z])/,'\1_\2').
gsub('/' ,'__').