From 01b1a8772928fbf31180341356981b95d0581413 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 29 Jan 2006 00:37:39 +0000 Subject: Added reusable reloading support through the inclusion of the Relodable module that all subclasses of ActiveRecord::Base, ActiveRecord::Observer, ActiveController::Base, and ActionMailer::Base automatically gets [DHH]. Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar]. Refactored extensions to module, class, and object in active support [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3493 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/module/inclusion.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/module/inclusion.rb (limited to 'activesupport/lib/active_support/core_ext/module/inclusion.rb') diff --git a/activesupport/lib/active_support/core_ext/module/inclusion.rb b/activesupport/lib/active_support/core_ext/module/inclusion.rb new file mode 100644 index 0000000000..124c4551bc --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/inclusion.rb @@ -0,0 +1,15 @@ +class Module + def remove_classes_including + included_in_classes.each { |klass| Class.remove_class(klass) } + end + + def included_in_classes + classes = [] + ObjectSpace.each_object(Class) { |k| classes << k if k.included_modules.include?(self) } + + classes.reverse.inject([]) do |unique_classes, klass| + unique_classes << klass unless unique_classes.collect { |k| k.to_s }.include?(klass.to_s) + unique_classes + end + end +end \ No newline at end of file -- cgit v1.2.3