<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>vendor/plugins/aaa/test/include_into_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,7 +3,7 @@
 
 Module.class_eval do
   # A hash that maps Class names to an array of Modules to mix in when the class is instantiated.
-  @@class_mixins = {}
+  @@class_mixins = {} unless defined?(@@class_mixins)
   mattr_reader :class_mixins
 
   # Specifies that this module should be included into the given classes when they are instantiated.
@@ -11,18 +11,46 @@ Module.class_eval do
   #   module FooMethods
   #     include_into &quot;Foo&quot;, &quot;Bar&quot;
   #   end
+  #
+  # You can also specify a hash to have your module's methods alias_method_chained to the target 
+  # class' methods.
+  #
+  #   module FooMethods
+  #      include_into &quot;Foo&quot;, :method =&gt; :feature
+  #   end
+  #
+  # This will alias Foo#method to the newly included FooMethods#method_with_feature. The former
+  # method Foo#method will continue to be available as Foo#method_without_feature.
+  #
   def include_into(*klasses)
     klasses.flatten!
+    aliases = klasses.last.is_a?(Hash) ? klasses.pop : {}
     klasses.each do |klass|
-      (@@class_mixins[klass] ||= []) &lt;&lt; name.to_s
+      (@@class_mixins[klass] ||= []) &lt;&lt; [name.to_s, aliases]
       @@class_mixins[klass].uniq!
     end
   end
-  
+
   # add any class mixins that have been registered for this class
   def auto_include!
-    mixins = @@class_mixins[name]
-    send(:include, *mixins.collect { |name| name.constantize }) if mixins
+    if mixins = @@class_mixins[name]
+      mixins.each do |name, aliases| 
+        include name.constantize
+        aliases.each { |args| alias_chain *args }
+      end
+    end
+  end
+  
+  def alias_chain(target, feature)
+    (class &lt;&lt; self; self end).class_eval &lt;&lt;-EOC, __FILE__, __LINE__      
+      def method_added_with_#{target}_#{feature}(method)
+        if method == :#{target} &amp;&amp; !method_defined?(:#{target}_without_#{feature})
+          alias_method_chain :#{target}, :#{feature}
+        end
+        method_added_without_#{target}_#{feature}(method)
+      end
+      alias_method_chain :method_added, :#{target}_#{feature}
+    EOC
   end
 end
 </diff>
      <filename>vendor/plugins/aaa/init.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7af009a57222f56ad33aa9527f323321ff39320e</id>
    </parent>
  </parents>
  <author>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </author>
  <url>http://github.com/halorgium/mephisto/commit/d971d941df4351ad42b41896b3446f3d43fa9bcd</url>
  <id>d971d941df4351ad42b41896b3446f3d43fa9bcd</id>
  <committed-date>2008-02-06T13:27:46-08:00</committed-date>
  <authored-date>2008-02-06T13:27:46-08:00</authored-date>
  <message>Enhance include_into with alias_method_chaining, closing #152</message>
  <tree>8441e1a82843804d1bace8fcceea3aaedb60e87a</tree>
  <committer>
    <name>Sven Fuchs</name>
    <email>svenfuchs@artweb-design.de</email>
  </committer>
</commit>
