Skip to content

Commit

Permalink
the data structure used to store attribute aliases should not be exposed
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jul 1, 2013
1 parent a444ea3 commit d094aaa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions activemodel/lib/active_model/attribute_methods.rb
Expand Up @@ -218,6 +218,16 @@ def alias_attribute(new_name, old_name)
end
end

# Is +new_name+ an alias?
def attribute_alias?(new_name)
attribute_aliases.key? new_name.to_s
end

# Returns the original name for the alias +name+
def attribute_alias(name)
attribute_aliases[name.to_s]
end

# Declares the attributes that should be prefixed and suffixed by
# ActiveModel::AttributeMethods.
#
Expand Down
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/relation/predicate_builder.rb
Expand Up @@ -6,8 +6,8 @@ def self.build_from_hash(klass, attributes, default_table)
attributes.each do |column, value|
table = default_table

if column.is_a?(Symbol) && klass.attribute_aliases.key?(column.to_s)
column = klass.attribute_aliases[column.to_s]
if column.is_a?(Symbol) && klass.attribute_alias?(column)
column = klass.attribute_alias(column.to_s)
end

if value.is_a?(Hash)
Expand Down

0 comments on commit d094aaa

Please sign in to comment.