Skip to content
This repository
Browse code

the data structure used to store attribute aliases should not be exposed

  • Loading branch information...
commit d094aaad19ab0d79d0e74747ad1a7141f914b431 1 parent a444ea3
Aaron Patterson tenderlove authored
10 activemodel/lib/active_model/attribute_methods.rb
@@ -218,6 +218,16 @@ def alias_attribute(new_name, old_name)
218 218 end
219 219 end
220 220
  221 + # Is +new_name+ an alias?
  222 + def attribute_alias?(new_name)
  223 + attribute_aliases.key? new_name.to_s
  224 + end
  225 +
  226 + # Returns the original name for the alias +name+
  227 + def attribute_alias(name)
  228 + attribute_aliases[name.to_s]
  229 + end
  230 +
221 231 # Declares the attributes that should be prefixed and suffixed by
222 232 # ActiveModel::AttributeMethods.
223 233 #
4 activerecord/lib/active_record/relation/predicate_builder.rb
@@ -6,8 +6,8 @@ def self.build_from_hash(klass, attributes, default_table)
6 6 attributes.each do |column, value|
7 7 table = default_table
8 8
9   - if column.is_a?(Symbol) && klass.attribute_aliases.key?(column.to_s)
10   - column = klass.attribute_aliases[column.to_s]
  9 + if column.is_a?(Symbol) && klass.attribute_alias?(column)
  10 + column = klass.attribute_alias(column.to_s)
11 11 end
12 12
13 13 if value.is_a?(Hash)

0 comments on commit d094aaa

Please sign in to comment.
Something went wrong with that request. Please try again.