public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Make the options that has_many, belongs_to and other association generation 
methods can accept, configurable.

[#985 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Hongli Lai (Phusion) (author)
Sat Sep 06 09:37:31 -0700 2008
jeremy (committer)
Tue Sep 09 12:50:32 -0700 2008
commit  16929404417205792165153958ce5effa0b54645
tree    c453953748164336795b8ceb1cc91f886b9144b5
parent  07913788f99f45a3c4ca41b518885468ac3a3915
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Internal API: configurable association options so plugins may extend and override.  #985 [Hongli Lai]
0
+
0
 * Changed benchmarks to be reported in milliseconds [DHH]
0
 
0
 * Connection pooling.  #936 [Nick Sieger]
...
1509
1510
1511
 
 
 
 
 
 
 
 
 
 
 
 
 
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
 
1524
1525
1526
1527
1528
1529
 
 
 
 
 
 
 
1530
1531
1532
1533
 
1534
1535
1536
...
1542
1543
1544
 
 
 
 
 
 
 
1545
1546
1547
1548
1549
 
1550
1551
1552
...
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
 
 
 
 
 
 
 
 
 
 
 
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
 
 
 
1541
1542
1543
1544
...
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
 
 
 
 
1561
1562
1563
1564
0
@@ -1509,28 +1509,36 @@ module ActiveRecord
0
           end
0
         end
0
 
0
+        mattr_accessor :valid_keys_for_has_many_association
0
+        @@valid_keys_for_has_many_association = [
0
+          :class_name, :table_name, :foreign_key, :primary_key,
0
+          :dependent,
0
+          :select, :conditions, :include, :order, :group, :limit, :offset,
0
+          :as, :through, :source, :source_type,
0
+          :uniq,
0
+          :finder_sql, :counter_sql,
0
+          :before_add, :after_add, :before_remove, :after_remove,
0
+          :extend, :readonly,
0
+          :validate, :accessible
0
+        ]
0
+
0
         def create_has_many_reflection(association_id, options, &extension)
0
-          options.assert_valid_keys(
0
-            :class_name, :table_name, :foreign_key, :primary_key,
0
-            :dependent,
0
-            :select, :conditions, :include, :order, :group, :limit, :offset,
0
-            :as, :through, :source, :source_type,
0
-            :uniq,
0
-            :finder_sql, :counter_sql,
0
-            :before_add, :after_add, :before_remove, :after_remove,
0
-            :extend, :readonly,
0
-            :validate, :accessible
0
-          )
0
+          options.assert_valid_keys(valid_keys_for_has_many_association)
0
 
0
           options[:extend] = create_extension_modules(association_id, extension, options[:extend])
0
 
0
           create_reflection(:has_many, association_id, options, self)
0
         end
0
 
0
+        mattr_accessor :valid_keys_for_has_one_association
0
+        @@valid_keys_for_has_one_association = [
0
+          :class_name, :foreign_key, :remote, :select, :conditions, :order,
0
+          :include, :dependent, :counter_cache, :extend, :as, :readonly,
0
+          :validate, :primary_key, :accessible
0
+        ]
0
+
0
         def create_has_one_reflection(association_id, options)
0
-          options.assert_valid_keys(
0
-            :class_name, :foreign_key, :remote, :select, :conditions, :order, :include, :dependent, :counter_cache, :extend, :as, :readonly, :validate, :primary_key, :accessible
0
-          )
0
+          options.assert_valid_keys(valid_keys_for_has_one_association)
0
 
0
           create_reflection(:has_one, association_id, options, self)
0
         end
0
@@ -1542,11 +1550,15 @@ module ActiveRecord
0
           create_reflection(:has_one, association_id, options, self)
0
         end
0
 
0
+        mattr_accessor :valid_keys_for_belongs_to_association
0
+        @@valid_keys_for_belongs_to_association = [
0
+          :class_name, :foreign_key, :foreign_type, :remote, :select, :conditions,
0
+          :include, :dependent, :counter_cache, :extend, :polymorphic, :readonly,
0
+          :validate, :accessible
0
+        ]
0
+
0
         def create_belongs_to_reflection(association_id, options)
0
-          options.assert_valid_keys(
0
-            :class_name, :foreign_key, :foreign_type, :remote, :select, :conditions, :include, :dependent,
0
-            :counter_cache, :extend, :polymorphic, :readonly, :validate, :accessible
0
-          )
0
+          options.assert_valid_keys(valid_keys_for_belongs_to_association)
0
 
0
           reflection = create_reflection(:belongs_to, association_id, options, self)
0
 

Comments