method
replace_named_bind_variables
v7.0.0 -
Show latest stable
- Class:
ActiveRecord::Sanitization::ClassMethods
replace_named_bind_variables(statement, bind_vars)private
No documentation available.
# File activerecord/lib/active_record/sanitization.rb, line 174
def replace_named_bind_variables(statement, bind_vars)
statement.gsub(/(:?):([a-zA-Z]\w*)/) do |match|
if $1 == ":" # skip postgresql casts
match # return the whole match
elsif bind_vars.include?(match = $2.to_sym)
replace_bind_variable(bind_vars[match])
else
raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}"
end
end
end