aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/customer.rb
Commit message (Collapse)AuthorAgeFilesLines
* Ensure hashes can be passed to attributes using `composed_of`Sean Griffin2016-05-311-1/+6
| | | | | | | | | | | This behavior was broken by 36e9be85. When the value is assigned directly, either through mass assignment or directly assigning a hash, the hash gets passed through to this writer method directly. While this is intended to handle certain cases, when an explicit converter has been provided, we should continue to use that instead. The positioning of the added guard caused the new behavior to override that case. Fixes #25210
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-271-0/+7
| | | | | | | | | | | 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
* Removing composed_of from ActiveRecord.Steve Klabnik2012-06-181-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature adds a lot of complication to ActiveRecord for dubious value. Let's talk about what it does currently: class Customer < ActiveRecord::Base composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) end Instead, you can do something like this: def balance @balance ||= Money.new(value, currency) end def balance=(balance) self[:value] = balance.value self[:currency] = balance.currency @balance = balance end Since that's fairly easy code to write, and doesn't need anything extra from the framework, if you use composed_of today, you'll have to add accessors/mutators like that. Closes #1436 Closes #2084 Closes #3807
* Refactor aggregation writer methodCarlos Antonio da Silva2012-05-211-1/+0
| | | | Only constantize class_name once.
* allow the :converter Proc form composed_of to return nilYves Senn2012-05-031-0/+5
| | | | | | | This makes it possible to filter invalid input values before they are passed into the value-object (like empty strings). This behaviour is only relevant if the :allow_nil options is set to true. Otherwise you will get the resulting NoMethodError.
* send() will raise an ArgumentError, so we should leverage rubyAaron Patterson2011-01-071-1/+1
|
* Added :constructor and :converter options to composed_of and deprecated the ↵Rob Anderton2008-09-101-1/+19
| | | | | | conversion block Signed-off-by: Michael Koziarski <michael@koziarski.com>
* move assets and modelsJeremy Kemper2008-01-181-0/+55
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de