aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-05-03 00:47:50 +0100
committerJon Leighton <j@jonathanleighton.com>2012-05-04 12:50:07 +0100
commit4bd9482a1a890c50264b4a9320e6853f1a0bde69 (patch)
tree2ce874f35c75b40210aed34949b2639c34251324 /activerecord
parent75a22814ef331ebeb35ee827699fc4177984921f (diff)
downloadrails-4bd9482a1a890c50264b4a9320e6853f1a0bde69.tar.gz
rails-4bd9482a1a890c50264b4a9320e6853f1a0bde69.tar.bz2
rails-4bd9482a1a890c50264b4a9320e6853f1a0bde69.zip
de-globalise method
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/dynamic_matchers.rb9
-rw-r--r--activerecord/lib/active_record/reflection.rb4
-rw-r--r--activerecord/lib/active_record/sanitization.rb2
3 files changed, 6 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/dynamic_matchers.rb b/activerecord/lib/active_record/dynamic_matchers.rb
index f3f143940f..96a3a69d0d 100644
--- a/activerecord/lib/active_record/dynamic_matchers.rb
+++ b/activerecord/lib/active_record/dynamic_matchers.rb
@@ -63,9 +63,7 @@ module ActiveRecord
def expand_attribute_names_for_aggregates
attribute_names.map do |attribute_name|
if aggregation = model.reflect_on_aggregation(attribute_name.to_sym)
- model.send(:aggregate_mapping, aggregation).map do |field_attr, _|
- field_attr.to_sym
- end
+ aggregation.mapping.map { |m| m.first.to_sym }
else
attribute_name.to_sym
end
@@ -240,10 +238,5 @@ module ActiveRecord
"create!"
end
end
-
- def aggregate_mapping(reflection)
- mapping = reflection.options[:mapping] || [reflection.name, reflection.name]
- mapping.first.is_a?(Array) ? mapping : [mapping]
- end
end
end
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index d4f4d593c6..c380b5c029 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -153,6 +153,10 @@ module ActiveRecord
# Holds all the meta-data about an aggregation as it was specified in the
# Active Record class.
class AggregateReflection < MacroReflection #:nodoc:
+ def mapping
+ mapping = options[:mapping] || [name, name]
+ mapping.first.is_a?(Array) ? mapping : [mapping]
+ end
end
# Holds all the meta-data about an association as it was specified in the
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb
index 81b13fe529..5530be3219 100644
--- a/activerecord/lib/active_record/sanitization.rb
+++ b/activerecord/lib/active_record/sanitization.rb
@@ -58,7 +58,7 @@ module ActiveRecord
expanded_attrs = {}
attrs.each do |attr, value|
if aggregation = reflect_on_aggregation(attr.to_sym)
- mapping = aggregate_mapping(aggregation)
+ mapping = aggregation.mapping
mapping.each do |field_attr, aggregate_attr|
if mapping.size == 1 && !value.respond_to?(aggregate_attr)
expanded_attrs[field_attr] = value