Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Expansion on require method from runtime.rb

  • Loading branch information...
commit da69c5d8bf5ac4a81de3870eb51a7833bbe79ef5 1 parent 69d5259
@radar radar authored fxn committed
Showing with 36 additions and 1 deletion.
  1. +36 −1 railties/guides/source/initialization.textile
View
37 railties/guides/source/initialization.textile
@@ -2229,9 +2229,44 @@ The second +require+ method here:
load(gemfile).require(*groups)
</ruby>
-Is defined on _bundler/runtime.rb_
+Is defined on _bundler/runtime.rb_:
+<ruby>
+ def require(*groups)
+ groups.map! { |g| g.to_sym }
+ groups = [:default] if groups.empty?
+ autorequires = autorequires_for_groups(*groups)
+
+ groups.each do |group|
+ (autorequires[group] || [[]]).each do |path, explicit|
+ if explicit
+ Kernel.require(path)
+ else
+ begin
+ Kernel.require(path)
+ rescue LoadError
+ end
+ end
+ end
+ end
+ end
+</ruby>
+
+This method does TODO: Describe what magic this undertakes.
+The first method to be called here is +autorequires_for_groups+:
+
+<ruby>
+ def autorequires_for_groups(*groups)
+ groups.map! { |g| g.to_sym }
+ autorequires = Hash.new { |h,k| h[k] = [] }
+
+ ordered_deps = []
+ specs_for(*groups).each do |g|
+ dep = @definition.dependencies.find{|d| d.name == g.name }
+ ordered_deps << dep if dep && !ordered_deps.include?(dep)
+ end
+</ruby>
h3. Firing it up!
Please sign in to comment.
Something went wrong with that request. Please try again.