aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-03-01 23:52:36 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-03-01 23:52:36 +0000
commit02ba03509c6a0f3e0fde99f0172a0125c83e43ce (patch)
treee2e66a47e24660eb763dc9056e9276c90f6af9b2 /activerecord/lib
parentcaf8976ce786a1d6dca69a448da394dbddd53f12 (diff)
downloadrails-02ba03509c6a0f3e0fde99f0172a0125c83e43ce.tar.gz
rails-02ba03509c6a0f3e0fde99f0172a0125c83e43ce.tar.bz2
rails-02ba03509c6a0f3e0fde99f0172a0125c83e43ce.zip
Added better defaults for composed_of, so statements like composed_of :time_zone, :mapping => %w( time_zone time_zone ) can be written without the mapping part (it's now assumed)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@821 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/aggregations.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index 6a82e53b03..208dc35321 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -118,12 +118,13 @@ module ActiveRecord
# composed_of :temperature, :mapping => %w(reading celsius)
# composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
# composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ]
+ # composed_of :gps_location
def composed_of(part_id, options = {})
validate_options([ :class_name, :mapping ], options.keys)
name = part_id.id2name
class_name = options[:class_name] || name_to_class_name(name)
- mapping = options[:mapping]
+ mapping = options[:mapping] || [ name, name ]
reader_method(name, class_name, mapping)
writer_method(name, class_name, mapping)