Merge pull request #20410 from schneems/schneems/boo-global-vars

Use block variable instead of global
This commit is contained in:
Rafael Mendonça França 2015-06-01 23:17:42 -03:00
commit c87cce1ddf
3 changed files with 5 additions and 5 deletions

View File

@ -55,7 +55,7 @@ module ActionDispatch
def unescape_uri(uri) def unescape_uri(uri)
encoding = uri.encoding == US_ASCII ? UTF_8 : uri.encoding encoding = uri.encoding == US_ASCII ? UTF_8 : uri.encoding
uri.gsub(ESCAPED) { [$&[1, 2].hex].pack('C') }.force_encoding(encoding) uri.gsub(ESCAPED) { |match| [match[1, 2].hex].pack('C') }.force_encoding(encoding)
end end
protected protected

View File

@ -68,9 +68,9 @@ module ActiveSupport
def camelize(term, uppercase_first_letter = true) def camelize(term, uppercase_first_letter = true)
string = term.to_s string = term.to_s
if uppercase_first_letter if uppercase_first_letter
string = string.sub(/^[a-z\d]*/) { inflections.acronyms[$&] || $&.capitalize } string = string.sub(/^[a-z\d]*/) { |match| inflections.acronyms[match] || match.capitalize }
else else
string = string.sub(/^(?:#{inflections.acronym_regex}(?=\b|[A-Z_])|\w)/) { $&.downcase } string = string.sub(/^(?:#{inflections.acronym_regex}(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
end end
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" } string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" }
string.gsub!('/'.freeze, '::'.freeze) string.gsub!('/'.freeze, '::'.freeze)

View File

@ -117,9 +117,9 @@ rescue LoadError
def camelize(uppercase_first_letter = true) def camelize(uppercase_first_letter = true)
string = self string = self
if uppercase_first_letter if uppercase_first_letter
string = string.sub(/^[a-z\d]*/) { $&.capitalize } string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
else else
string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase } string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
end end
string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::') string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
end end