Skip to content

Commit

Permalink
Changing const_regexp to check for constant name.
Browse files Browse the repository at this point in the history
We need to return Regexp.escape(camel_cased_word)
if the split is blank.
  • Loading branch information
arunagw committed Jun 14, 2013
1 parent 85bb7d9 commit 07d8294
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions activesupport/lib/active_support/inflector/methods.rb
Expand Up @@ -322,6 +322,9 @@ def ordinalize(number)
# For instance, Foo::Bar::Baz will generate Foo(::Bar(::Baz)?)? # For instance, Foo::Bar::Baz will generate Foo(::Bar(::Baz)?)?
def const_regexp(camel_cased_word) #:nodoc: def const_regexp(camel_cased_word) #:nodoc:
parts = camel_cased_word.split("::") parts = camel_cased_word.split("::")

return Regexp.escape(camel_cased_word) if parts.blank?

last = parts.pop last = parts.pop


parts.reverse.inject(last) do |acc, part| parts.reverse.inject(last) do |acc, part|
Expand Down

0 comments on commit 07d8294

Please sign in to comment.