diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-19 07:57:55 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-19 07:57:55 -0300 |
commit | 85b78fcda5cff62409ba60df779155d00bf073bc (patch) | |
tree | 9f6c00284f24d1a39ff3920ae35f72f8a9fc20c7 /activerecord/lib/active_record | |
parent | d4cec3124085ee7070986d13e9e44664d0aa9d2a (diff) | |
parent | 113f56d31d5e0fb60a69ab995b8f51705de7213d (diff) | |
download | rails-85b78fcda5cff62409ba60df779155d00bf073bc.tar.gz rails-85b78fcda5cff62409ba60df779155d00bf073bc.tar.bz2 rails-85b78fcda5cff62409ba60df779155d00bf073bc.zip |
Merge pull request #15160 from sgrif/sg-destructured-each
Use destructured arguments when looping through pairs
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/aggregations.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 0d5313956b..45c275a017 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -230,8 +230,8 @@ module ActiveRecord private def reader_method(name, class_name, mapping, allow_nil, constructor) define_method(name) do - if @aggregation_cache[name].nil? && (!allow_nil || mapping.any? {|pair| !read_attribute(pair.first).nil? }) - attrs = mapping.collect {|pair| read_attribute(pair.first)} + if @aggregation_cache[name].nil? && (!allow_nil || mapping.any? {|key, _| !read_attribute(key).nil? }) + attrs = mapping.collect {|key, _| read_attribute(key)} object = constructor.respond_to?(:call) ? constructor.call(*attrs) : class_name.constantize.send(constructor, *attrs) @@ -249,10 +249,10 @@ module ActiveRecord end if part.nil? && allow_nil - mapping.each { |pair| self[pair.first] = nil } + mapping.each { |key, _| self[key] = nil } @aggregation_cache[name] = nil else - mapping.each { |pair| self[pair.first] = part.send(pair.last) } + mapping.each { |key, value| self[key] = part.send(value) } @aggregation_cache[name] = part.freeze end end |