diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-27 18:21:29 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-27 19:25:14 -0300 |
commit | f4d818d51e64a025f78fca15fdae2391ed072656 (patch) | |
tree | 67fc2a0868bb4fc2c333fae88fffae340661681d /activerecord/test/models/customer.rb | |
parent | c01810dbec7dc4112c0f8b9bd78709c6db9a3e2d (diff) | |
download | rails-f4d818d51e64a025f78fca15fdae2391ed072656.tar.gz rails-f4d818d51e64a025f78fca15fdae2391ed072656.tar.bz2 rails-f4d818d51e64a025f78fca15fdae2391ed072656.zip |
Revert "Removing composed_of from ActiveRecord."
This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592.
Reason: we need to discuss a better path from this removal.
Conflicts:
activerecord/lib/active_record/reflection.rb
activerecord/test/cases/base_test.rb
activerecord/test/models/developer.rb
Diffstat (limited to 'activerecord/test/models/customer.rb')
-rw-r--r-- | activerecord/test/models/customer.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/models/customer.rb b/activerecord/test/models/customer.rb index 594c484f20..7e8e82542f 100644 --- a/activerecord/test/models/customer.rb +++ b/activerecord/test/models/customer.rb @@ -1,5 +1,12 @@ class Customer < ActiveRecord::Base cattr_accessor :gps_conversion_was_run + + composed_of :address, :mapping => [ %w(address_street street), %w(address_city city), %w(address_country country) ], :allow_nil => true + composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money } + composed_of :gps_location, :allow_nil => true + composed_of :non_blank_gps_location, :class_name => "GpsLocation", :allow_nil => true, :mapping => %w(gps_location gps_location), + :converter => lambda { |gps| self.gps_conversion_was_run = true; gps.blank? ? nil : GpsLocation.new(gps)} + composed_of :fullname, :mapping => %w(name to_s), :constructor => Proc.new { |name| Fullname.parse(name) }, :converter => :parse end class Address |