Skip to content
Browse files

patch remove_child_module_constants with @thedarkone 's suggestion fo…

…r resolving issues from thedarkone#33
  • Loading branch information...
1 parent 83b6ea8 commit e035c2ea353a0f063ddd58a3df8d32908c3f7358 @ssoroka committed
Showing with 13 additions and 9 deletions.
  1. +13 −9 lib/rails_development_boost/dependencies_patch.rb
View
22 lib/rails_development_boost/dependencies_patch.rb
@@ -282,15 +282,22 @@ def autoloaded_object?(object) # faster than going through Dependencies.autoload
def remove_child_module_constants(object, object_const_name)
object.constants.each do |child_const_name|
# we only care about "namespace" constants (classes/modules)
- if local_const_defined?(object, child_const_name) && (child_const = object.const_get(child_const_name)).kind_of?(Module)
- # make sure this is not "const alias" created like this: module Y; end; module A; X = Y; end, const A::X is not a proper "namespacing module",
- # but only an alias to Y module
- if (full_child_const_name = child_const._mod_name) == "#{object_const_name}::#{child_const_name}"
- remove_child_module_constant(object, full_child_const_name)
+ if local_const_defined?(object, child_const_name)
+ child_const =
+ begin
+ object.const_get(child_const_name)
+ rescue NameError
+ end
+ if child_const.kind_of?(Module)
+ # make sure this is not "const alias" created like this: module Y; end; module A; X = Y; end, const A::X is not a proper "namespacing module",
+ # but only an alias to Y module
+ if (full_child_const_name = child_const._mod_name) == "#{object_const_name}::#{child_const_name}"
+ remove_child_module_constant(object, full_child_const_name)
+ end
end
end
end
- end
+ end
def remove_child_module_constant(parent_object, full_child_const_name)
remove_constant(full_child_const_name)
@@ -364,9 +371,6 @@ def prevent_further_removal_of(const_name)
constants_being_removed << const_name
begin
yield
- rescue NameError
- # NameError exceptions here will hide the real exception being raised.
- # Just ignore them; they're not important.
ensure
constants_being_removed.delete(const_name)
end

0 comments on commit e035c2e

Please sign in to comment.
Something went wrong with that request. Please try again.