aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/aggregations.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-01-19 03:45:24 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-01-19 03:45:24 +0000
commitabdf546ad6d02ecb95766e73cd3c645a48c954de (patch)
treee783b20e18305f1210bea2250130891e634d5aa3 /activerecord/lib/active_record/aggregations.rb
parent3877dfc72b126f5009c7ea53c03d83a72425db10 (diff)
downloadrails-abdf546ad6d02ecb95766e73cd3c645a48c954de.tar.gz
rails-abdf546ad6d02ecb95766e73cd3c645a48c954de.tar.bz2
rails-abdf546ad6d02ecb95766e73cd3c645a48c954de.zip
Support aggregations in finder conditions. Closes #10572.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8671 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/aggregations.rb')
-rw-r--r--activerecord/lib/active_record/aggregations.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index f0f34e9a99..cad8304bcf 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -108,6 +108,15 @@ module ActiveRecord
#
# Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not keeping value objects
# immutable on http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable
+ #
+ # == Finding records by a value object
+ #
+ # Once a +composed_of+ relationship is specified for a model, records can be loaded from the database by specifying an instance
+ # of the value object in the conditions hash. The following example finds all customers with +balance_amount+ equal to 20 and
+ # +balance_currency+ equal to "USD":
+ #
+ # Customer.find(:all, :conditions => {:balance => Money.new(20, "USD")})
+ #
module ClassMethods
# Adds reader and writer methods for manipulating a value object:
# <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods.