aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-20 22:44:33 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-20 22:44:33 -0200
commitf058e565c1f7ab36199887a56696edb01d85e2cf (patch)
tree814c534c56afa0e1e15b89621dd2eea2f2475e3e /activerecord/lib/active_record/persistence.rb
parentf042b4e88e614448cd5a98113f896de042a70af2 (diff)
downloadrails-f058e565c1f7ab36199887a56696edb01d85e2cf.tar.gz
rails-f058e565c1f7ab36199887a56696edb01d85e2cf.tar.bz2
rails-f058e565c1f7ab36199887a56696edb01d85e2cf.zip
Remove return guard and use code convetions
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 1c17c578e9..eed49e17b1 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -180,7 +180,7 @@ module ActiveRecord
name = name.to_s
verify_readonly_attribute(name)
send("#{name}=", value)
- save(:validate => false)
+ save(validate: false)
end
# Updates the attributes of the model from the passed-in hash and saves the
@@ -235,8 +235,8 @@ module ActiveRecord
updated_count = self.class.where(self.class.primary_key => id).update_all(attributes)
- attributes.each do |k,v|
- raw_write_attribute(k,v)
+ attributes.each do |k, v|
+ raw_write_attribute(k, v)
end
updated_count == 1
@@ -388,10 +388,14 @@ module ActiveRecord
# Returns the number of affected rows.
def update(attribute_names = @attributes.keys)
attributes_with_values = arel_attributes_with_values_for_update(attribute_names)
- return 0 if attributes_with_values.empty?
- klass = self.class
- stmt = klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.compile_update(attributes_with_values)
- klass.connection.update stmt
+
+ if attributes_with_values.empty?
+ 0
+ else
+ klass = self.class
+ stmt = klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.compile_update(attributes_with_values)
+ klass.connection.update stmt
+ end
end
# Creates a record with values matching those of the instance attributes