Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

r1609@asus: jeremy | 2005-07-03 00:18:43 -0700

 more minor perf tweaks


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1627 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit af9d03824a3db7d637532ce926a4e2d720602442 1 parent 397c8ee
@jeremy jeremy authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 activerecord/lib/active_record/base.rb
View
13 activerecord/lib/active_record/base.rb
@@ -1207,8 +1207,11 @@ def query_method?() /^([a-zA-Z][-_\w]*)\?$/ end
def read_attribute(attr_name)
if @attributes.keys.include? attr_name
if column = column_for_attribute(attr_name)
- unserializable_attribute?(attr_name, column) ?
- unserialize_attribute(attr_name) : column.type_cast(@attributes[attr_name])
+ if unserializable_attribute?(attr_name, column)
+ unserialize_attribute(attr_name)
+ else
+ column.type_cast(@attributes[attr_name])
+ end
else
@attributes[attr_name]
end
@@ -1223,7 +1226,9 @@ def read_attribute_before_type_cast(attr_name)
# Returns true if the attribute is of a text column and marked for serialization.
def unserializable_attribute?(attr_name, column)
- @attributes[attr_name] && [:text, :string].include?(column.send(:type)) && @attributes[attr_name].is_a?(String) && self.class.serialized_attributes[attr_name]
+ if value = @attributes[attr_name]
+ [:text, :string].include?(column.send(:type)) && value.is_a?(String) && self.class.serialized_attributes[attr_name]
+ end
end
# Returns the unserialized object of the attribute.
@@ -1301,7 +1306,7 @@ def attributes_with_quotes(include_primary_key = true)
# Quote strings appropriately for SQL statements.
def quote(value, column = nil)
- connection.quote(value, column)
+ self.class.connection.quote(value, column)
end
# Interpolate custom sql string in instance context.
Please sign in to comment.
Something went wrong with that request. Please try again.