aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/aggregations.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-06 14:18:01 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-06 14:24:16 -0600
commit36e9be8524ff524ac5ea51dd1fc6ee33cfe4285a (patch)
tree975bdf30a004091e7d0a25cfd9fce25e3c807c26 /activerecord/lib/active_record/aggregations.rb
parent6680ee9427ae2639e404cd3b9538f54e136057c6 (diff)
downloadrails-36e9be8524ff524ac5ea51dd1fc6ee33cfe4285a.tar.gz
rails-36e9be8524ff524ac5ea51dd1fc6ee33cfe4285a.tar.bz2
rails-36e9be8524ff524ac5ea51dd1fc6ee33cfe4285a.zip
Remove composed_of special case from multi-parameter attributes
As we move towards removing the `klass` method from `column`, the else clause as it stands right now will become the only case.
Diffstat (limited to 'activerecord/lib/active_record/aggregations.rb')
-rw-r--r--activerecord/lib/active_record/aggregations.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index 45c275a017..4fead8d251 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -244,6 +244,10 @@ module ActiveRecord
def writer_method(name, class_name, mapping, allow_nil, converter)
define_method("#{name}=") do |part|
klass = class_name.constantize
+ if part.is_a?(Hash)
+ part = klass.new(*part.values)
+ end
+
unless part.is_a?(klass) || converter.nil? || part.nil?
part = converter.respond_to?(:call) ? converter.call(part) : klass.send(converter, part)
end