Skip to content

Commit

Permalink
Constantize a regexp in Dependencies#load_missing_constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan del Strother authored and fxn committed Aug 13, 2011
1 parent 1d64041 commit f1403f9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion activesupport/lib/active_support/dependencies.rb
Expand Up @@ -466,6 +466,7 @@ def qualified_name_for(mod, name)
# Load the constant named +const_name+ which is missing from +from_mod+. If # Load the constant named +const_name+ which is missing from +from_mod+. If
# it is not possible to load the constant into from_mod, try its parent module # it is not possible to load the constant into from_mod, try its parent module
# using const_missing. # using const_missing.
THIS_FILE = %r{#{Regexp.escape(__FILE__)}}
def load_missing_constant(from_mod, const_name) def load_missing_constant(from_mod, const_name)
log_call from_mod, const_name log_call from_mod, const_name


Expand All @@ -478,7 +479,7 @@ def load_missing_constant(from_mod, const_name)
qualified_name = qualified_name_for from_mod, const_name qualified_name = qualified_name_for from_mod, const_name
path_suffix = qualified_name.underscore path_suffix = qualified_name.underscore


trace = caller.reject {|l| l =~ %r{#{Regexp.escape(__FILE__)}}} trace = caller.reject {|l| l =~ THIS_FILE}
name_error = NameError.new("uninitialized constant #{qualified_name}") name_error = NameError.new("uninitialized constant #{qualified_name}")
name_error.set_backtrace(trace) name_error.set_backtrace(trace)


Expand Down

0 comments on commit f1403f9

Please sign in to comment.