aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/class/removal.rb14
-rw-r--r--activesupport/lib/active_support/core_ext/module/inclusion.rb4
2 files changed, 5 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/removal.rb b/activesupport/lib/active_support/core_ext/class/removal.rb
index 8fc4d728b3..468c77d81b 100644
--- a/activesupport/lib/active_support/core_ext/class/removal.rb
+++ b/activesupport/lib/active_support/core_ext/class/removal.rb
@@ -7,15 +7,11 @@ class Class #:nodoc:
Object.subclasses_of(self).map { |o| o.to_s }
end
- def remove_class(klass)
- if klass.to_s.include? "::"
- modules = klass.to_s.split("::")
- final_klass = modules.pop
-
- final_module = modules.inject(Object) { |final_type, part| final_type.const_get(part) }
- final_module.send(:remove_const, final_klass) rescue nil
- else
- Object.send(:remove_const, klass.to_s) rescue nil
+ def remove_class(*klasses)
+ klasses.each do |klass|
+ basename = klass.to_s.split("::").last
+ parent = klass.parent
+ parent.send :remove_const, basename unless parent == klass
end
end
end \ No newline at end of file
diff --git a/activesupport/lib/active_support/core_ext/module/inclusion.rb b/activesupport/lib/active_support/core_ext/module/inclusion.rb
index 124c4551bc..efc00d6f28 100644
--- a/activesupport/lib/active_support/core_ext/module/inclusion.rb
+++ b/activesupport/lib/active_support/core_ext/module/inclusion.rb
@@ -1,8 +1,4 @@
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) }