aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-29 21:14:58 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-29 21:14:58 +0000
commit4290267959e8c91b8f2a4898d3fa33b15b8b7d57 (patch)
tree080250de03a99e133150ce58614073d771309897 /activerecord/lib/active_record/associations.rb
parent84d5519b74f831d31caf00a018ca0c3b60ebb643 (diff)
downloadrails-4290267959e8c91b8f2a4898d3fa33b15b8b7d57.tar.gz
rails-4290267959e8c91b8f2a4898d3fa33b15b8b7d57.tar.bz2
rails-4290267959e8c91b8f2a4898d3fa33b15b8b7d57.zip
Moved support into Active Support
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@277 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rwxr-xr-xactiverecord/lib/active_record/associations.rb57
1 files changed, 1 insertions, 56 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index ccad4120d9..13396c48b1 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -3,30 +3,6 @@ require 'active_record/associations/has_many_association'
require 'active_record/associations/has_and_belongs_to_many_association'
require 'active_record/deprecated_associations'
-
-unless Object.respond_to?(:require_association)
- Object.send(:define_method, :require_association) { |file_name| ActiveRecord::Base.require_association(file_name) }
-end
-
-class Object
- class << self
- # Use const_missing to autoload associations so we don't have to
- # require_association when using single-table inheritance.
- unless respond_to?(:pre_association_const_missing)
- alias_method :pre_association_const_missing, :const_missing
-
- def const_missing(class_id)
- begin
- require_association(Inflector.underscore(Inflector.demodulize(class_id.to_s)))
- return Object.const_get(class_id) if Object.const_defined?(class_id) && Object.const_get(class_id).ancestors.include?(ActiveRecord::Base)
- rescue LoadError
- pre_association_const_missing(class_id)
- end
- end
- end
- end
-end
-
module ActiveRecord
module Associations # :nodoc:
def self.append_features(base)
@@ -478,31 +454,6 @@ module ActiveRecord
deprecated_has_collection_method(association_name)
end
- # Loads the <tt>file_name</tt> if reload_associations is true or requires if it's false.
- def require_association(file_name)
- if !associations_loaded.include?(file_name)
- associations_loaded << file_name
- reload_associations ? silence_warnings { load("#{file_name}.rb") } : require(file_name)
- end
- end
-
- # Resets the list of dependencies loaded (typically to be called by the end of a request), so when require_association is
- # called for that dependency it'll be loaded anew.
- def reset_associations_loaded
- self.associations_loaded = []
- end
-
- # Reload all the associations that have already been loaded once.
- def reload_associations_loaded
- associations_loaded.each do |file_name|
- begin
- silence_warnings { load("#{file_name}.rb") }
- rescue LoadError
- # The association didn't reside in its own file, so we assume it was required by other means
- end
- end
- end
-
private
# Raises an exception if an invalid option has been specified to prevent misspellings from slipping through
def validate_options(valid_option_keys, supplied_option_keys)
@@ -619,13 +570,7 @@ module ActiveRecord
end
def require_association_class(class_name)
- return unless class_name
-
- begin
- require_association(Inflector.underscore(class_name))
- rescue LoadError
- # Failed to load the associated class -- let's hope the developer is doing the requiring himself.
- end
+ require_association(Inflector.underscore(class_name)) if class_name
end
end
end