<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,27 +1,25 @@
 class Array
   def add(a)
     raise(ArgumentError, &quot;the two arrays must have the same size&quot;) if self.size != a.size
-    (0..a.size-1).map do |i| 
-      self[i] + a[i]
-    end    
+    (0..a.size-1).map {|i| self[i] + a[i] }
   end
 
   # used to merge all the types in one row
   # I think need some refactor
   def group_by_types
-    array=[]; final_array=[];
+    array, final_array = [], [];
     
     self.each do |i|
        array &lt;&lt; self.map { |j| j if i[:day] == j[:day] and i[:month] == j[:month] and i[:year] == j[:year] }.compact.map {|s| s[:type] }.flatten
     end
     
-    i=0;
+    i = 0;
     self.map do |j| 
-      j[:type]=array[i]
-      found_final_array=false
+      j[:type] = array[i]
+      found_final_array = false
       final_array.each { |a| found_final_array = true if a == j }
       final_array &lt;&lt; j unless found_final_array
-      i+=1
+      i+= 1
     end
     final_array
   end</diff>
      <filename>lib/stats_for_all/array.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,18 @@
 require 'yaml'
 module StatsForAll
   CONFIGURATION = {}
-  RAILS_ENV = Rails.env rescue &quot;test&quot;
-  # RAILS_ROOT = 
   
   def self.load_configuration()
     app_config_file = File.expand_path(File.dirname(__FILE__) + &quot;../../../../../../config/stats_for_all.yml&quot;)
 
     # file config only loaded for the test environment
     app_config_file = File.expand_path(File.dirname(__FILE__) + &quot;../../../test/stats_for_all.yml&quot;) if RAILS_ENV == &quot;test&quot;
-
     
     if File.exist?(app_config_file)
       CONFIGURATION.merge!(YAML.load(File.read(app_config_file))[&quot;all&quot;] || {}) 
       CONFIGURATION.merge!(YAML.load(File.read(app_config_file))[RAILS_ENV || &quot;test&quot;] || {})
     end
+    
   end
 end
 </diff>
      <filename>lib/stats_for_all/config_load.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,14 +14,9 @@
 #  created_at :datetime
 #  updated_at :datetime
 #
-
 class Stat &lt; ActiveRecord::Base
   TYPE = StatsForAll::CONFIGURATION[&quot;types&quot;]
-  
-  StatsForAll::CONFIGURATION[&quot;model&quot;].each do | model |
-    self.class_eval(&quot;belongs_to :#{model.downcase.singularize} , :polymorphic =&gt; true&quot;)
-  end
-      
+
   named_scope :is_like, lambda { |*args| {:conditions =&gt; { :stat_type =&gt; args.first.stat_type, 
                                                            :model_type =&gt; args.first.model_type,
                                                            :model_id =&gt; args.first.model_id } } }</diff>
      <filename>lib/stats_for_all/stat.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 require 'drb'
+require 'ruby-debug'
+
 module StatsForAll
   module Client
 
@@ -7,9 +9,11 @@ module StatsForAll
     end 
 
     module ClassMethods 
-      def stats_for_me(options={})
+      def stats_for_me(types = {})
         has_many :stats, :dependent =&gt; :destroy, :as =&gt; :model
-
+                
+        Stat.class_eval(&quot;belongs_to :#{self.class.name.downcase.singularize} , :polymorphic =&gt; true&quot;)
+        
         include StatsForAll::Client::InstanceMethods 
       end
     end
@@ -17,9 +21,9 @@ module StatsForAll
     module InstanceMethods 
 
       # Cool syntax stats retrieve supported!, like:
-      # @object.stat :type=&gt; Stat::TYPE[:click], :day =&gt; 21..24, :month =&gt;10..12, :year =&gt; 2007..2009
-      # @object.stat :type=&gt; Stat::TYPE[:click], :day =&gt; 21, :month =&gt;10, :year =&gt; 2008
-      # @object.stat :type=&gt; Stat::TYPE[:click], :month =&gt;10, :year =&gt; 2008
+      # @object.stat :type=&gt; Stat::TYPE[:click], :day =&gt; 21..24, :month =&gt; 10..12, :year =&gt; 2007..2009
+      # @object.stat :type=&gt; Stat::TYPE[:click], :day =&gt; 21, :month =&gt; 10, :year =&gt; 2008
+      # @object.stat :type=&gt; Stat::TYPE[:click], :month =&gt; 10, :year =&gt; 2008
       # @object.stat :type=&gt; Stat::TYPE[:click], :year =&gt; 2008
 
       def stat(arg={})
@@ -35,7 +39,7 @@ module StatsForAll
       def save_stats(type, hour=Time.now.hour)
         case StatsForAll::CONFIGURATION[&quot;increment_type&quot;]
         when &quot;direct&quot;
-         direct_save(type, hour)
+          direct_save(type, hour)
         when &quot;starling&quot;
           starling_save(type, hour)
         when &quot;drb&quot;
@@ -199,7 +203,7 @@ module StatsForAll
         DRb.stop_service
         value
       end
-      
+
       def get_stats_server_connection
         stats_server = DRbObject.new(nil, &quot;druby://#{StatsForAll::CONFIGURATION[&quot;server_host&quot;]}:#{StatsForAll::CONFIGURATION[&quot;server_port&quot;]}&quot;)  
         begin                                                      
@@ -210,7 +214,7 @@ module StatsForAll
           get_stats_server_connection
         end        
       end
-      
-    end
+
+    end    
   end    
 end</diff>
      <filename>lib/stats_for_all/stats_for_all_client.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 require 'rubygems'
-require 'active_record'
 require 'yaml'
+require 'active_record'
 require 'drb'
 require File.expand_path(File.dirname(__FILE__) + '/stats_for_all')
 
-
 class StatsForAllRunner
   def start
     print &quot;Starting SuperStat drb server....&quot;</diff>
      <filename>lib/stats_for_all_runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,8 @@
 require 'rubygems'
-require 'daemons'
 require 'active_record'
 require 'drb'
 require 'yaml'                                                                 
+require 'daemons'
 
 module StatsForAll
   RAILS_ENV = ARGV.pop</diff>
      <filename>lib/stats_for_all_server_demonized.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ class CreateStatsForAll &lt; ActiveRecord::Migration
     add_index :stats, [:day], :name =&gt;&quot;idx_stats_day&quot;
     add_index :stats, [:month], :name =&gt;&quot;idx_stats_month&quot;
     add_index :stats, [:year], :name =&gt;&quot;idx_stats_year&quot;    
-    add_index :stats, [:stat_type], :name =&gt;&quot;idx_stats_stat_type&quot;    
+    add_index :stats, [:stat_type], :name =&gt;&quot;idx_stats_stat_type&quot;
   end
 
   def self.down</diff>
      <filename>templates/create_stats_for_all.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,5 @@
-all:
-  model: [ ] # example: [ banner, photo, car ]
-  
-  types: { click: 0, hit: 1}
+all:  
+  types: { click: 0, hit: 1 }
   
   # no need if you work in &quot;direct mode&quot; only  
   server_host: localhost</diff>
      <filename>templates/stats_for_all.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,4 @@
 all:
-  model: [ banner ]
-  
   types: { click: 0, hit: 1 }
   
   # require for increment_type: drb and starling only</diff>
      <filename>test/stats_for_all.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require File.expand_path(File.dirname(__FILE__) + '/stats_for_all_test_helper') 
+require 'ruby-debug'
 
 class BannerTest &lt; Test::Unit::TestCase  
   def setup
@@ -19,6 +20,10 @@ class BannerTest &lt; Test::Unit::TestCase
    should &quot;have the correct general stat&quot; do 
       assert_equal 3, @art.click_counter       
     end  
+    
+    should &quot;have denfined correctly the relation&quot; do
+      assert_equal Banner, @stat1.model.class
+    end
   end  
     
   context &quot;A stats_for_all_client&quot; do
@@ -46,12 +51,10 @@ class BannerTest &lt; Test::Unit::TestCase
       assert_equal Time.days_in_month(Time.now.month), @art.clicks(:month =&gt; Time.now.month, :year =&gt; Time.now.year).size
       assert_equal 4, @art.clicks( :month =&gt; Time.now.month, :year =&gt; Time.now.year).sum
 
-
       assert_equal 12, @art.clicks(:year =&gt; Time.now.year).size
       assert_equal 4, @art.clicks( :year =&gt; Time.now.year).sum      
       
-      assert_equal 12, @art.clicks.size       
-
+      assert_equal 12, @art.clicks.size
     end
     
     
@@ -92,7 +95,7 @@ class BannerTest &lt; Test::Unit::TestCase
         @art2_result = [{:type=&gt;[&quot;hit&quot;], :day=&gt;Time.now.day, :month=&gt;Time.now.month, :year=&gt;Time.now.year}]
         @art2.stats.first.update_all_stats
         
-        StatsForAll::CONFIGURATION[&quot;increment_type&quot;]=&quot;direct&quot;
+        StatsForAll::CONFIGURATION[&quot;increment_type&quot;] = &quot;direct&quot;
       end
 
       should &quot;have the correct available months, days and years in the correct format&quot; do</diff>
      <filename>test/stats_for_all_client_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ require 'shoulda/rails'
 require 'factory_girl'
 
 module StatsForAll
-  RAILS_ENV = 'test'
+  RAILS_ENV = 'test' 
 end
 
 require File.expand_path(File.dirname(__FILE__) + '/../lib/stats_for_all') 
@@ -17,6 +17,7 @@ ActiveRecord::Base.establish_connection(YAML.load_file(File.expand_path(File.dir
 
 ActiveRecord::Base.send(:include, StatsForAll::Client)
 
+
 def setup_db
   ActiveRecord::Schema.define(:version =&gt; 1) do
     create_table &quot;banners&quot;, :force =&gt; true do |t|
@@ -53,7 +54,7 @@ def teardown_db
 end
 
 class Banner &lt; ActiveRecord::Base
-  stats_for_me
+  stats_for_me click: 3, a: 0, hit: 1, 
 end
 
 Factory.define :banner do |b|</diff>
      <filename>test/stats_for_all_test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>03b3a1dedfcd6c17c7e10155249482bc6e766f41</id>
    </parent>
  </parents>
  <author>
    <name>Felipe Talavera</name>
    <email>felipe.talavera@gmail.com</email>
  </author>
  <url>http://github.com/flype/stats_for_all/commit/6e4dc3f19472adb07038933322d21ea7a2f1d675</url>
  <id>6e4dc3f19472adb07038933322d21ea7a2f1d675</id>
  <committed-date>2009-10-17T14:34:08-07:00</committed-date>
  <authored-date>2009-10-17T14:34:08-07:00</authored-date>
  <message>now the model config it's not necesary</message>
  <tree>cff8035c69fc9a814a686f7f3ae5313952098ad9</tree>
  <committer>
    <name>Felipe Talavera</name>
    <email>felipe.talavera@gmail.com</email>
  </committer>
</commit>
