diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-01 23:52:36 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-03-01 23:52:36 +0000 |
commit | 02ba03509c6a0f3e0fde99f0172a0125c83e43ce (patch) | |
tree | e2e66a47e24660eb763dc9056e9276c90f6af9b2 /activerecord/test/fixtures/customer.rb | |
parent | caf8976ce786a1d6dca69a448da394dbddd53f12 (diff) | |
download | rails-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/test/fixtures/customer.rb')
-rw-r--r-- | activerecord/test/fixtures/customer.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/fixtures/customer.rb b/activerecord/test/fixtures/customer.rb index 5275a5209d..c36d4d33a8 100644 --- a/activerecord/test/fixtures/customer.rb +++ b/activerecord/test/fixtures/customer.rb @@ -1,6 +1,7 @@ class Customer < ActiveRecord::Base composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ] composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) + composed_of :gps_location end class Address @@ -27,4 +28,20 @@ class Money def exchange_to(other_currency) Money.new((amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor, other_currency) end +end + +class GpsLocation + attr_reader :gps_location + + def initialize(gps_location) + @gps_location = gps_location + end + + def latitude + gps_location.split("x").first + end + + def longitude + gps_location.split("x").last + end end
\ No newline at end of file |