Improved to_app_model.

This commit is contained in:
Martin Edenhofer 2013-09-20 13:40:25 +02:00
parent b3bda95b7c
commit d6d21e6cfe

View file

@ -1,6 +1,10 @@
class Class
def to_app_model
name = self.to_s.downcase
name.gsub( /::/, '_' )
camel_cased_word = self.to_s
camel_cased_word.gsub(/::/, '_').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
end