aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-08-03 13:59:34 -0300
committerEmilio Tagua <miloops@gmail.com>2009-08-03 13:59:34 -0300
commit31c83534d61cad2203ae57087442caedb4dbf22a (patch)
tree43f5c75abe5a3169956a47a3c5ca163aea7c0992 /activerecord/lib/active_record/base.rb
parent62296a51c80b93fedcae896a534862687c8fef94 (diff)
downloadrails-31c83534d61cad2203ae57087442caedb4dbf22a.tar.gz
rails-31c83534d61cad2203ae57087442caedb4dbf22a.tar.bz2
rails-31c83534d61cad2203ae57087442caedb4dbf22a.zip
Don't use local vars before testing its conditional.
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 2b50333682..2f1f6175af 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1068,7 +1068,7 @@ module ActiveRecord #:nodoc:
# If the access logic of your application is richer you can use <tt>Hash#except</tt>
# or <tt>Hash#slice</tt> to sanitize the hash of parameters before they are
# passed to Active Record.
- #
+ #
# For example, it could be the case that the list of protected attributes
# for a given model depends on the role of the user:
#
@@ -1116,7 +1116,7 @@ module ActiveRecord #:nodoc:
# If the access logic of your application is richer you can use <tt>Hash#except</tt>
# or <tt>Hash#slice</tt> to sanitize the hash of parameters before they are
# passed to Active Record.
- #
+ #
# For example, it could be the case that the list of accessible attributes
# for a given model depends on the role of the user:
#
@@ -2968,14 +2968,14 @@ module ActiveRecord #:nodoc:
attrs = {}
attribute_names.each do |name|
if (column = column_for_attribute(name)) && (include_primary_key || !column.primary)
- value = read_attribute(name)
if include_readonly_attributes || (!include_readonly_attributes && !self.class.readonly_attributes.include?(name))
- # We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML.
- if value && self.class.serialized_attributes.has_key?(name) && (value.acts_like?(:date) || value.acts_like?(:time))
+ value = read_attribute(name)
+
+ if value && ((self.class.serialized_attributes.has_key?(name) && (value.acts_like?(:date) || value.acts_like?(:time))) || value.is_a?(Hash) || value.is_a?(Array))
value = value.to_yaml
end
- attrs[arel_table[name]] = (value.is_a?(Hash) || value.is_a?(Array)) ? value.to_yaml : value
+ attrs[arel_table[name]] = value
end
end
end