From 02ba03509c6a0f3e0fde99f0172a0125c83e43ce Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 1 Mar 2005 23:52:36 +0000 Subject: 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 --- activerecord/test/fixtures/customer.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'activerecord/test/fixtures/customer.rb') 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 -- cgit v1.2.3