aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures/customer.rb
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/test/fixtures/customer.rb
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/test/fixtures/customer.rb')
-rw-r--r--activerecord/test/fixtures/customer.rb17
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