mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Rails 2.2 compat
This commit is contained in:
parent
793ee3dd11
commit
275007843e
@ -25,7 +25,7 @@ module AMS
|
||||
#
|
||||
# camelize(underscore('SSLError')) # => "SslError"
|
||||
def underscore(camel_cased_word)
|
||||
return camel_cased_word unless /[A-Z-]|::/.match?(camel_cased_word)
|
||||
return camel_cased_word unless /[A-Z-]|::/.match(camel_cased_word)
|
||||
word = camel_cased_word.to_s.gsub("::".freeze, "/".freeze)
|
||||
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
|
||||
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user