提交 c70aee8e 编写于 作者: R Roque Pinel

Use block variable instead of global

上级 3d949f34
......@@ -119,9 +119,9 @@ def replace_bind_variable(value, c = connection) #:nodoc:
end
def replace_named_bind_variables(statement, bind_vars) #:nodoc:
statement.gsub(/(:?):([a-zA-Z]\w*)/) do
statement.gsub(/(:?):([a-zA-Z]\w*)/) do |match|
if $1 == ':' # skip postgresql casts
$& # return the whole match
match # return the whole match
elsif bind_vars.include?(match = $2.to_sym)
replace_bind_variable(bind_vars[match])
else
......
......@@ -153,7 +153,7 @@ def humanize(lower_case_and_underscored_word, options = {})
# titleize('TheManWithoutAPast') # => "The Man Without A Past"
# titleize('raiders_of_the_lost_ark') # => "Raiders Of The Lost Ark"
def titleize(word)
humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { $&.capitalize }
humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { |match| match.capitalize }
end
# Creates the name of a table like Rails does for models to table names.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册