0
@@ -6,32 +6,32 @@ module Merb
0
- cattr_accessor :_subclasses
0
- class_inheritable_accessor :_after, :_before
0
+ cattr_accessor :subclasses
0
+ class_inheritable_accessor :after, :before
0
- unless klass._before || klass._after
0
- _subclasses << klass.to_s
0
- _subclasses.insert(_subclasses.index(klass._before), klass)
0
+ unless klass.before || klass.after
0
+ subclasses << klass.to_s
0
+ subclasses.insert(subclasses.index(klass.before), klass)
0
-
_subclasses.insert(_subclasses.index(klass._before) + 1, klass)
0
+
subclasses.insert(subclasses.index(klass.before) + 1, klass)
0
-
_subclasses.each {|klass| klass.new.run! }
0
+
subclasses.each {|klass| klass.new.run! }
0
@@ -58,6 +58,8 @@ class Merb::BootLoader::BuildFramework < Merb::BootLoader
0
class Merb::BootLoader::LoadPaths < Merb::BootLoader
0
# Add models, controllers, and lib to the load path
0
$LOAD_PATH.unshift Merb.load_paths[:model].first if Merb.load_paths[:model]
0
@@ -66,7 +68,95 @@ class Merb::BootLoader::LoadPaths < Merb::BootLoader
0
# Require all the files in the registered load paths
0
Merb.load_paths.each do |name, path|
0
- Dir[path.first / path.last].each {|f| require f}
0
+ Dir[path.first / path.last].each do |file|
0
+ klasses = ObjectSpace.classes.dup
0
+ LOADED_CLASSES[file] = ObjectSpace.classes - klasses
0
+ if klasses = LOADED_CLASSES[file]
0
+ klasses.each do |klass|
0
+ remove_constant(klass)
0
+ def remove_constant(const)
0
+ # This is to support superclasses (like AbstractController) that track
0
+ # their subclasses in a class variable. Classes that wish to use this
0
+ # functionality are required to alias it to _subclasses_list. Plugins
0
+ # for ORMs and other libraries should keep this in mind.
0
+ if klass.superclass.respond_to?(:_subclasses_list)
0
+ klass.superclass.send(:_subclasses_list).delete(klass)
0
+ klass.superclass.send(:_subclasses_list).delete(klass.to_s)
0
+ parts = const.to_s.split("::")
0
+ base = parts.size == 1 ? Object : Object.full_const_get(parts[0..-2].join("::"))
0
+ object = parts[-1].intern
0
+ Merb.logger.debugger("Removing constant #{object} from #{base}")
0
+ base.send(:remove_const, object) if object
0
+class Merb::BootLoader::Templates < Merb::BootLoader
0
+ template_paths.each do |path|
0
+ Merb::Template.inline_template(path)
0
+ extension_glob = "{#{Merb::Template::EXTENSIONS.keys.join(',')}}"
0
+ # This gets all templates set in the controllers template roots
0
+ # We separate the two maps because most of controllers will have
0
+ # the same _template_root, so it's silly to be globbing the same
0
+ template_paths = Merb::AbstractController._abstract_subclasses.map do |klass|
0
+ end.uniq.map {|path| Dir["#{path}/**/*.#{extension_glob}"] }
0
+ # This gets the templates that might be created outside controllers
0
+ # template roots. eg app/views/shared/*
0
+ template_paths << Dir["#{Merb.load_paths[:view]}/**/*.#{extension_glob}"]
0
+ template_paths.flatten.compact.uniq
0
+class Merb::BootLoader::Libraries < Merb::BootLoader
0
+ @@libraries = {:disable_json_gem => %[json/ext json/pure]}
0
+ # Add other libraries to load in early in the boot process
0
+ # hsh<Hash[exclude, tries]>:: A hash or libraries to add
0
+ # Exclude this library if Merb::Config[exclude] is true
0
+ # tries<Array[String]>::
0
+ # Try to require each item in the Array in succesion. If the item is not found,
0
+ # try the next one. If none of the items are found, raise a LoadError.
0
+ def self.add_libraries(hsh)
0
+ @@libraries.merge!(hsh)
0
+ @@libraries.each do |exclude, choices|
0
+ require_first_working(*choices) unless Merb::Config[exclude]
0
+ def require_first_working(first, *rest)
0
+ raise LoadError if rest.empty?
0
+ require_first_working rest.unshift, *rest
0
\ No newline at end of file
Comments
No one has commented yet.