Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
al6x committed Oct 29, 2011
1 parent 531c105 commit 2805dcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/class_loader.rb
@@ -1,8 +1,13 @@
autoload :ClassLoader, 'class_loader/class_loader'

class Module
alias_method :const_missing_without_autoload, :const_missing
alias_method :const_missing_without_cl, :const_missing
def const_missing const
ClassLoader.load(self, const) || const_missing_without_autoload(const)
ClassLoader.load(self, const) || begin
const_missing_without_cl(const)
rescue => e
# Removing ClassLoader from backtrace.
raise e.class, e.message, ClassLoader.filter_backtrace(e.backtrace)
end
end
end
8 changes: 4 additions & 4 deletions lib/class_loader/class_loader.rb
Expand Up @@ -94,6 +94,10 @@ def watcher
@watcher ||= ClassLoader::Watcher.new monitor
end

def filter_backtrace backtrace
backtrace.reject{|path| path.include?("/lib/class_loader") or path.include?('monitor.rb')}
end

protected
# Use this method to define class name to file name mapping, by default it uses underscored paths,
# but You can override this method to use camel case for example.
Expand Down Expand Up @@ -134,9 +138,5 @@ def name_hack namespace
""
end
end

def filter_backtrace backtrace
backtrace.reject{|path| path.include?("/lib/class_loader") or path.include?('monitor.rb')}
end
end
end

0 comments on commit 2805dcd

Please sign in to comment.