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 class Class
def to_app_model def to_app_model
name = self.to_s.downcase camel_cased_word = self.to_s
name.gsub( /::/, '_' ) 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
end end