def disable_dependency_loading
if configuration.cache_classes && !configuration.dependency_loading
ActiveSupport::Dependencies.unhook!
end
end
ActiveSupport::Dependencies.unhook! は以下。
# activesupport-2.3.3/lib/active_support/dependencies.rb
def unhook!
ModuleConstMissing.excluded(Module)
Loadable.excluded(Object)
true
end
ModuleConstMissing は、同じファイル内で定義されているモジュール。
# activesupport-2.3.3/lib/active_support/dependencies.rb
module ModuleConstMissing #:nodoc:
def self.included(base) #:nodoc:
base.class_eval do
unless defined? const_missing_without_dependencies
alias_method_chain :const_missing, :dependencies
end
end
end
def self.excluded(base) #:nodoc:
base.class_eval do
if defined? const_missing_without_dependencies
undef_method :const_missing
alias_method :const_missing, :const_missing_without_dependencies
undef_method :const_missing_without_dependencies
end
end
end
~~ 略 ~~
end
ModuleConstMissing::excluded を呼び出すことで、included で置き換えていた const_missing メソッドを元に戻します。
Loadable も同様。
# activesupport-2.3.3/lib/active_support/dependencies.rb
module Loadable #:nodoc:
def self.included(base) #:nodoc:
base.class_eval do
unless defined? load_without_new_constant_marking
alias_method_chain :load, :new_constant_marking
end
end
end
def self.excluded(base) #:nodoc:
base.class_eval do
if defined? load_without_new_constant_marking
undef_method :load
alias_method :load, :load_without_new_constant_marking
undef_method :load_without_new_constant_marking
end
end
end
~~ 略 ~~
end
Loadable::excluded を呼び出すことで、included で置き換えていた load メソッドを元に戻します。
[Rails][CodeReading] Railsの初期化コードを読む (イントロ&目次)
これが、Initializer.process の最後のメソッドになる。
詳細まで追えなかったメソッドもあったけれど、ひとまず完了ー。
0 件のコメント:
コメントを投稿