<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,15 +3,41 @@
 # Free to modify and redistribute with credit.
 # See README for usage.
 
-class ::Object
-  def self.augment(*mods)
-    include *mods
-    mods.each {|mod| class_eval &amp;mod.augmentation }
+class ::AugmentationModule &lt; ::Module
+  attr_reader :augmentation
+  
+  def included(klass)
+    raise &quot;Cannot 'include' an AugmentationModule: use 'augment' instead.&quot;
+  end
+  
+  def initialize(&amp;block)
+    @augmentation = block
   end
 end
 
-class ::Module
-  def augmentation(&amp;block)
-    @augmentation ||= block
+class ::Object
+  def self.augment(*mods)
+    @options_during_augmentation = mods.last.is_a?(::Hash) ? mods.pop : {}
+    def self.options_during_augmentation
+      @options_during_augmentation.dup
+    end
+    
+    mods.each do |mod|
+      raise ::ArgumentError.new(&quot;#{mod.name} is not an AugmentationModule&quot;) unless mod.is_a?(::AugmentationModule)
+      class_eval &amp;mod.augmentation if mod.augmentation
+    end
+    
+    remove_instance_variable(:@options_during_augmentation)
+    (class&lt;&lt;self; self; end).send :remove_method, :options_during_augmentation
+  end
+  
+  def augmentation_module(modname=nil, &amp;block)
+    newmod = ::AugmentationModule.new(&amp;block)
+    
+    who = respond_to?(:const_set) ? self : ::Kernel
+    who.const_set( modname, newmod ) if modname
+    
+    newmod
   end
+  private :augmentation_module
 end</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,26 +4,54 @@ require File.join(File.dirname(__FILE__), '../init')
 class ModelBase
   def self.belongs_to(x) @belongs_to = x end
   def self.has_one(x) @has_one = x end
+  def self.nested_belongs_to(x) @nested_belongs_to = x end
+  def self.nested_has_one(x) @nested_has_one = x end
 end
 
-module ModuleOne
-  augmentation do    
-     belongs_to :test
-     def an_instance_method?() true end
-     def self.belongs_to?(x) @belongs_to == x end
+augmentation_module :ModuleOne do
+  belongs_to :test
+  def an_instance_method?() true end
+  def self.belongs_to?(x) @belongs_to == x end
+end
+
+ModuleTwo = augmentation_module do
+  has_one :test
+  def another_instance_method?() true end
+  def self.has_one?(x) @has_one == x end
+end
+
+augmentation_module :ModuleWithArgs do
+  if options_during_augmentation[ :auth_by_password ]
+    def self.authentication_methods() [:password, :cookie, :session] end
+  else
+    def self.authentication_methods() [:cookie, :session] end
   end
 end
 
-module ModuleTwo
-  augmentation do    
-     has_one :test
-     def another_instance_method?() true end
-     def self.has_one?(x) @has_one == x end
+module OuterModule
+  augmentation_module :InnerModuleOne do
+    nested_belongs_to :test
+    def a_nested_instance_method?() true end
+    def self.nested_belongs_to?(x) @nested_belongs_to == x end
+  end
+  
+  InnerModuleTwo = augmentation_module do
+    nested_has_one :test
+    def another_nested_instance_method?() true end
+    def self.nested_has_one?(x) @nested_has_one == x end
   end
 end
 
 class MyModel &lt; ModelBase
-  augment ModuleOne, ModuleTwo
+  augment ModuleOne, ModuleTwo, OuterModule::InnerModuleOne, OuterModule::InnerModuleTwo
+end
+
+class MyArgModelOne
+  augment ModuleWithArgs
+end
+
+class MyArgModelTwo
+  augment ModuleWithArgs, :auth_by_password =&gt; true
 end
 
 
@@ -32,12 +60,21 @@ class AugmentationsTest &lt; Test::Unit::TestCase
   def test_calling_and_defining_class_methods
     assert MyModel.belongs_to?(:test)
     assert MyModel.has_one?(:test)
+    assert MyModel.nested_belongs_to?(:test)
+    assert MyModel.nested_has_one?(:test)
   end
   
   def test_defining_instance_methods
     my_model = MyModel.new
     assert my_model.an_instance_method?
     assert my_model.another_instance_method?
+    assert my_model.a_nested_instance_method?
+    assert my_model.another_nested_instance_method?
+  end
+  
+  def test_passing_module_arguments
+    assert MyArgModelOne.authentication_methods == [:cookie, :session]
+    assert MyArgModelTwo.authentication_methods == [:password, :cookie, :session]
   end
 
 end</diff>
      <filename>test/augmentations_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>77fb517b399d95f4f04b9b396d185e9f5dc37a86</id>
    </parent>
  </parents>
  <author>
    <name>Jacob Radford</name>
    <email>jradford@hunter.cuny.edu</email>
  </author>
  <url>http://github.com/nkryptic/augmentations/commit/58f63dd01db68caeb4281cd8a01a771cee8c9899</url>
  <id>58f63dd01db68caeb4281cd8a01a771cee8c9899</id>
  <committed-date>2009-03-29T18:31:10-07:00</committed-date>
  <authored-date>2009-03-29T18:31:10-07:00</authored-date>
  <message>first attempt to use module arguments and not allow anything but augmenting code in module</message>
  <tree>c5c2144bd1b53c52c6ab59cee4ba80a9f8407ef1</tree>
  <committer>
    <name>Jacob Radford</name>
    <email>jradford@hunter.cuny.edu</email>
  </committer>
</commit>
