diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-21 18:34:31 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-21 18:34:58 -0300 |
commit | d5d9a281aaf9bc0fd7f5e92e1609a7677f25887c (patch) | |
tree | 360154517867e00d77360368892e6c4cf51c5b11 /activerecord/lib | |
parent | f260dc53be27448d9052098369d31d8ecd626839 (diff) | |
download | rails-d5d9a281aaf9bc0fd7f5e92e1609a7677f25887c.tar.gz rails-d5d9a281aaf9bc0fd7f5e92e1609a7677f25887c.tar.bz2 rails-d5d9a281aaf9bc0fd7f5e92e1609a7677f25887c.zip |
Refactor aggregation writer method
Only constantize class_name once.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/aggregations.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 5de10a8dd6..f0b549e5ad 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -242,10 +242,9 @@ module ActiveRecord def writer_method(name, class_name, mapping, allow_nil, converter) define_method("#{name}=") do |part| - unless part.is_a?(class_name.constantize) || converter.nil? || part.nil? - part = converter.respond_to?(:call) ? - converter.call(part) : - class_name.constantize.send(converter, part) + klass = class_name.constantize + unless part.is_a?(klass) || converter.nil? || part.nil? + part = converter.respond_to?(:call) ? converter.call(part) : klass.send(converter, part) end if part.nil? && allow_nil |