0
@@ -51,17 +51,28 @@ module ActiveSupport #:nodoc:
0
module ModuleConstMissing #:nodoc:
0
def self.included(base) #:nodoc:
0
- # Rename the original handler so we can chain it to the new one
0
- alias_method :rails_original_const_missing, :const_missing
0
+ unless defined? const_missing_without_dependencies
0
+ alias_method_chain :const_missing, :dependencies
0
- # Use const_missing to autoload associations so we don't have to
0
- # require_association when using single-table inheritance.
0
- def const_missing(class_id)
0
- ActiveSupport::Dependencies.load_missing_constant self, class_id
0
+ def self.excluded(base) #:nodoc:
0
+ if defined? const_missing_without_dependencies
0
+ undef_method :const_missing
0
+ alias_method :const_missing, :const_missing_without_dependencies
0
+ undef_method :const_missing_without_dependencies
0
+ # Use const_missing to autoload associations so we don't have to
0
+ # require_association when using single-table inheritance.
0
+ def const_missing_with_dependencies(class_id)
0
+ ActiveSupport::Dependencies.load_missing_constant self, class_id
0
def unloadable(const_desc = self)
0
@@ -92,8 +103,38 @@ module ActiveSupport #:nodoc:
0
# Object includes this module
0
module Loadable #:nodoc:
0
- def load(file, *extras) #:nodoc:
0
- Dependencies.new_constants_in(Object) { super }
0
+ def self.included(base) #:nodoc:
0
+ unless defined? load_without_new_constant_marking
0
+ alias_method_chain :load, :new_constant_marking
0
+ def self.excluded(base) #:nodoc:
0
+ if defined? load_without_new_constant_marking
0
+ alias_method :load, :load_without_new_constant_marking
0
+ undef_method :load_without_new_constant_marking
0
+ def require_or_load(file_name)
0
+ Dependencies.require_or_load(file_name)
0
+ def require_dependency(file_name)
0
+ Dependencies.depend_on(file_name)
0
+ def require_association(file_name)
0
+ Dependencies.associate_with(file_name)
0
+ def load_with_new_constant_marking(file, *extras) #:nodoc:
0
+ Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) }
0
rescue Exception => exception # errors from loading file
0
exception.blame_file! file
0
@@ -145,19 +186,18 @@ module ActiveSupport #:nodoc:
0
- Object.instance_eval do
0
- define_method(:require_or_load) { |file_name| Dependencies.require_or_load(file_name) } unless Object.respond_to?(:require_or_load)
0
- define_method(:require_dependency) { |file_name| Dependencies.depend_on(file_name) } unless Object.respond_to?(:require_dependency)
0
- define_method(:require_association) { |file_name| Dependencies.associate_with(file_name) } unless Object.respond_to?(:require_association)
0
- alias_method :load_without_new_constant_marking, :load
0
+ Object.instance_eval { include Loadable }
0
Module.instance_eval { include ModuleConstMissing }
0
Class.instance_eval { include ClassConstMissing }
0
Exception.instance_eval { include Blamable }
0
+ ModuleConstMissing.excluded(Module)
0
+ Loadable.excluded(Object)
0
@@ -560,4 +600,4 @@ module ActiveSupport #:nodoc:
0
-ActiveSupport::Dependencies.inject!
0
+ActiveSupport::Dependencies.hook!
Comments
No one has commented yet.