Created
March 20, 2010 12:29
-
-
Save bb/338645 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/templates/default/module/html/box_info.erb b/templates/default/module/html/box_info.erb | |
index e436984..49a0b48 100644 | |
--- a/templates/default/module/html/box_info.erb | |
+++ b/templates/default/module/html/box_info.erb | |
@@ -23,6 +23,13 @@ | |
<% n = n == 2 ? 1 : 2 %> | |
<% end %> | |
<% end %> | |
+ <% [[:class, "Extending"], [:instance, "Included in"]].each do |scope, name| %> | |
+ <% if (mixed_into = mixed_into(object, scope)).size > 0 %> | |
+ <dt class="r<%=n%>"><%= name %>:</dt> | |
+ <dd class="r<%=n%>"><%= mixed_into.sort_by {|o| o.path }.map {|o| linkify(o) }.join(", ") %></dd> | |
+ <% n = n == 2 ? 1 : 2 %> | |
+ <% end %> | |
+ <% end %> | |
<% unless object.root? %> | |
<dt class="r<%=n%> last">Defined in:</dt> | |
<dd class="r<%=n%> last"><%= erb(:defines) %></dd> | |
diff --git a/templates/default/module/setup.rb b/templates/default/module/setup.rb | |
index 487da69..3319641 100644 | |
--- a/templates/default/module/setup.rb | |
+++ b/templates/default/module/setup.rb | |
@@ -90,3 +90,17 @@ def scopes(list) | |
yield(items, scope) unless items.empty? | |
end | |
end | |
+ | |
+def mixed_into(object, scope) | |
+ if !defined? @@mixed_into | |
+ @@mixed_into = {:class => {}, :instance => {}} | |
+ @@mixed_into.keys.each do |scope| | |
+ list = run_verifier Registry.all(:class, :module) | |
+ list.each do |o| | |
+ o.mixins(scope).each { |mi| (@@mixed_into[scope][mi.path] ||= []) << o } | |
+ end | |
+ end | |
+ end | |
+ | |
+ @@mixed_into[scope][object.path] || [] | |
+end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment