aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-11-30 18:52:20 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-11-30 18:52:20 +0000
commitd82f73ecabe71fc3814eff0bd26f4f431f690266 (patch)
tree568ad503cf10c54acd2a945c317d81887b1eb20b /actionpack
parent5b38d8557122723aa7c11c28d4c2c93464982766 (diff)
downloadrails-d82f73ecabe71fc3814eff0bd26f4f431f690266.tar.gz
rails-d82f73ecabe71fc3814eff0bd26f4f431f690266.tar.bz2
rails-d82f73ecabe71fc3814eff0bd26f4f431f690266.zip
Abolished ActionController::Base.require_or_load in favor of require_dependency and ActiveRecord::Base.require_or_load in favor of require_association. Both methods are now also available in the global namespace when you need to require dependencies or associations outside of whats done automatically.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@32 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rwxr-xr-xactionpack/lib/action_controller/base.rb4
-rw-r--r--actionpack/lib/action_controller/dependencies.rb2
-rw-r--r--actionpack/lib/action_controller/helpers.rb2
3 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 22eb7dc0a3..1f4798b2a0 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -256,9 +256,11 @@ module ActionController #:nodoc:
end
# Loads the <tt>file_name</tt> if reload_dependencies is true or requires if it's false.
- def require_or_load(file_name)
+ def require_dependency(file_name)
reload_dependencies ? silence_warnings { load("#{file_name}.rb") } : require(file_name)
end
+
+ Object.send(:define_method, :require_dependency) { |file_name| ActiveRecord::Base.require_dependency(file_name) }
end
public
diff --git a/actionpack/lib/action_controller/dependencies.rb b/actionpack/lib/action_controller/dependencies.rb
index 6f092500d1..f087354c63 100644
--- a/actionpack/lib/action_controller/dependencies.rb
+++ b/actionpack/lib/action_controller/dependencies.rb
@@ -38,7 +38,7 @@ module ActionController #:nodoc:
def require_dependencies(layer, dependencies)
dependencies.flatten.each do |dependency|
begin
- require_or_load(dependency.to_s)
+ require_dependency(dependency.to_s)
rescue LoadError
raise LoadError, "Missing #{layer} #{dependency}.rb"
end
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb
index 9c88582288..3def790cc6 100644
--- a/actionpack/lib/action_controller/helpers.rb
+++ b/actionpack/lib/action_controller/helpers.rb
@@ -54,7 +54,7 @@ module ActionController #:nodoc:
file_name = Inflector.underscore(arg.to_s.downcase) + '_helper'
class_name = Inflector.camelize(file_name)
begin
- require_or_load(file_name)
+ require_dependency(file_name)
rescue LoadError
raise LoadError, "Missing helper file helpers/#{file_name}.rb"
end