aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependencies.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/dependencies.rb')
-rw-r--r--activesupport/lib/active_support/dependencies.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 2badad5f5f..41b7e00c0c 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -1,3 +1,11 @@
+require 'set'
+require 'active_support/inflector'
+require 'active_support/core_ext/name_error'
+require 'active_support/core_ext/object/blank'
+require 'active_support/core_ext/module/aliasing'
+require 'active_support/core_ext/module/attribute_accessors'
+require 'active_support/core_ext/module/introspection'
+
module ActiveSupport #:nodoc:
module Dependencies #:nodoc:
extend self
@@ -16,7 +24,7 @@ module ActiveSupport #:nodoc:
# Should we load files or require them?
mattr_accessor :mechanism
- self.mechanism = :load
+ self.mechanism = ENV['NO_RELOAD'] ? :require : :load
# The set of directories from which we may automatically load files. Files
# under these directories will be reloaded on each request in development mode,
@@ -328,7 +336,7 @@ module ActiveSupport #:nodoc:
# Search for a file in load_paths matching the provided suffix.
def search_for_file(path_suffix)
- path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb'
+ path_suffix = "#{path_suffix}.rb" unless path_suffix =~ /\.rb\Z/
load_paths.each do |root|
path = File.join(root, path_suffix)
return path if File.file? path
@@ -410,7 +418,7 @@ module ActiveSupport #:nodoc:
# If we have an anonymous module, all we can do is attempt to load from Object.
from_mod = Object if from_mod.name.blank?
- unless qualified_const_defined?(from_mod.name) && from_mod.name.constantize.object_id == from_mod.object_id
+ unless qualified_const_defined?(from_mod.name) && Inflector.constantize(from_mod.name).object_id == from_mod.object_id
raise ArgumentError, "A copy of #{from_mod} has been removed from the module tree but is still active!"
end
@@ -501,7 +509,7 @@ module ActiveSupport #:nodoc:
# Handle the case where the module has yet to be defined.
initial_constants = if qualified_const_defined?(mod_name)
- mod_name.constantize.local_constant_names
+ Inflector.constantize(mod_name).local_constant_names
else
[]
end
@@ -526,7 +534,7 @@ module ActiveSupport #:nodoc:
# Module still doesn't exist? Treat it as if it has no constants.
next [] unless qualified_const_defined?(mod_name)
- mod = mod_name.constantize
+ mod = Inflector.constantize(mod_name)
next [] unless mod.is_a? Module
new_constants = mod.local_constant_names - prior_constants
@@ -596,7 +604,7 @@ module ActiveSupport #:nodoc:
if names.size == 1 # It's under Object
parent = Object
else
- parent = (names[0..-2] * '::').constantize
+ parent = Inflector.constantize(names[0..-2] * '::')
end
log "removing constant #{const}"