<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/mailer_worker.rb</filename>
    </added>
    <added>
      <filename>spec/integration_spec.rb</filename>
    </added>
    <added>
      <filename>spec/mailer_worker_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1 +1,2 @@
-require 'asynch_mail'
\ No newline at end of file
+require 'asynch_mail'
+require 'mailer_worker'
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,6 @@
 module AsynchMail
   
   def self.included(base)
-    create_worker_class base
     base.class_eval do
       class &lt;&lt; self
         alias_method :orig_method_missing, :method_missing
@@ -19,36 +18,10 @@ module AsynchMail
 
         def queue_mail(method, *parameters)
           mail = self.send &quot;create_#{method}&quot;, *parameters
-          worker_class.send &quot;asynch_deliver_mail&quot;, mail
-        end
-
-        def worker_class
-          ancestors.each do |ancestor|
-            if Object.const_defined?(ancestor.to_s &lt;&lt; 'Worker')
-              return Object.const_get(ancestor.to_s &lt;&lt; 'Worker')
-            end
-          end
+          MailerWorker.send &quot;asynch_deliver_mail&quot;, :class =&gt; self.name, :mail =&gt; mail
         end
       end
     end
   end
   
-  private
-  
-  def self.create_worker_class(base)
-    worker_class = Class.new Workling::Base
-    Object.const_set(base.to_s &lt;&lt; 'Worker', worker_class)
-    worker_class.send :include, WorkerMethods
-  end
-  
-  module WorkerMethods
-    def deliver_mail(mail)
-      mailer_class.deliver mail
-    end
-    
-    private
-    def mailer_class
-      Object.const_get self.class.name[0..-7]
-    end
-  end
 end
\ No newline at end of file</diff>
      <filename>lib/asynch_mail.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,56 +1,19 @@
 require File.dirname(__FILE__) + '/spec_helper'
 
-class AsynchTestMailer &lt; ActionMailer::Base
-  include AsynchMail
-  
-  def test_mail(from, to)
-    @subject    = 'subject'
-    @body       = 'mail body'
-    @recipients = to
-    @from       = from
-    @sent_on    = Time.now
-    @headers    = {}
-  end
-end
-
-class InheritedTestMailer &lt; AsynchTestMailer; end
-
-describe AsynchTestMailer do
-  it &quot;should create a worker for the mailer&quot; do
-    AsynchTestMailerWorker.superclass.should == Workling::Base
-  end
-end
-
-describe AsynchTestMailerWorker, 'deliver_mail' do
-  it &quot;should send the mail back to the mailer&quot; do
-    AsynchTestMailer.should_receive(:deliver).with(:email)
-    AsynchTestMailerWorker.new.deliver_mail :email
-  end
-end
-
 describe AsynchTestMailer, 'deliver_test_mail' do
   it &quot;should create an email object&quot; do
-    AsynchTestMailerWorker.stub!(:asynch_deliver_mail)
+    MailerWorker.stub!(:asynch_deliver_mail)
     AsynchTestMailer.should_receive(:create_test_mail).with('noreply@autoki.de', 'joe@doe.com')
     AsynchTestMailer.deliver_test_mail 'noreply@autoki.de', 'joe@doe.com'
   end
   
   it &quot;should send the mail to the worker&quot; do
     AsynchTestMailer.stub!(:create_test_mail).and_return(:email)
-    AsynchTestMailerWorker.should_receive(:asynch_deliver_mail).with(:email)
+    MailerWorker.should_receive(:asynch_deliver_mail).with(:class =&gt; 'AsynchTestMailer', :mail =&gt; :email)
     AsynchTestMailer.deliver_test_mail 'noreply@autoki.de', 'joe@doe.com'
   end
 end
 
-describe InheritedTestMailer, 'deliver_test_mail' do
-  it &quot;should send the mail to the worker of the superclass&quot; do
-    InheritedTestMailer.stub!(:create_test_mail).and_return(:email)
-    AsynchTestMailerWorker.should_receive(:asynch_deliver_mail).with(:email)
-    InheritedTestMailer.deliver_test_mail 'noreply@autoki.de', 'joe@doe.com'
-  end
-end
-
-
 describe AsynchTestMailer, 'deliver_test_mail!' do
   it &quot;should deliver the mail&quot; do
     emails = ActionMailer::Base.deliveries</diff>
      <filename>spec/asynch_mail_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 PLUGIN_ROOT = File.dirname(__FILE__) + '/..'
-require PLUGIN_ROOT + '/lib/asynch_mail'
 
 require 'rubygems'
 gem 'actionmailer'
@@ -7,7 +6,30 @@ require 'actionmailer'
 
 module Workling
   class Base
+    def self.method_missing(method, *args, &amp;block)
+      if method.to_s =~ /^asynch_(.*)/
+        self.new.send $1, *args
+      else
+        super
+      end
+    end
   end
 end
 
-ActionMailer::Base.delivery_method = :test
\ No newline at end of file
+ActionMailer::Base.delivery_method = :test
+
+require PLUGIN_ROOT + '/lib/asynch_mail'
+require PLUGIN_ROOT + '/lib/mailer_worker'
+
+class AsynchTestMailer &lt; ActionMailer::Base
+  include AsynchMail
+  
+  def test_mail(from, to)
+    @subject    = 'subject'
+    @body       = 'mail body'
+    @recipients = to
+    @from       = from
+    @sent_on    = Time.now
+    @headers    = {}
+  end
+end</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c5fb34bee7cd8ecf23da1e34ba166645c9691b04</id>
    </parent>
  </parents>
  <author>
    <name>Alexander Lang</name>
    <email>alex@skywalker.local</email>
  </author>
  <url>http://github.com/langalex/workling_mailer/commit/6b3dc23da4b4e36fd972f06b08595b6a667ca996</url>
  <id>6b3dc23da4b4e36fd972f06b08595b6a667ca996</id>
  <committed-date>2008-05-20T11:10:00-07:00</committed-date>
  <authored-date>2008-05-20T11:10:00-07:00</authored-date>
  <message>switched from dynamically generating workers to one static worker as generated workers can't be autodiscovered by workling and workling also doesn't create a queue for methods in a worker included from a module.</message>
  <tree>dcba4e3efcd732c397d6cc721cbfc37205745e7f</tree>
  <committer>
    <name>Alexander Lang</name>
    <email>alex@skywalker.local</email>
  </committer>
</commit>
