Skip to content

Commit f058e56

Browse files
committed
Remove return guard and use code convetions
1 parent f042b4e commit f058e56

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

activerecord/lib/active_record/persistence.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def update_attribute(name, value)
180180
name = name.to_s
181181
verify_readonly_attribute(name)
182182
send("#{name}=", value)
183-
save(:validate => false)
183+
save(validate: false)
184184
end
185185

186186
# Updates the attributes of the model from the passed-in hash and saves the
@@ -235,8 +235,8 @@ def update_columns(attributes)
235235

236236
updated_count = self.class.where(self.class.primary_key => id).update_all(attributes)
237237

238-
attributes.each do |k,v|
239-
raw_write_attribute(k,v)
238+
attributes.each do |k, v|
239+
raw_write_attribute(k, v)
240240
end
241241

242242
updated_count == 1
@@ -388,10 +388,14 @@ def create_or_update
388388
# Returns the number of affected rows.
389389
def update(attribute_names = @attributes.keys)
390390
attributes_with_values = arel_attributes_with_values_for_update(attribute_names)
391-
return 0 if attributes_with_values.empty?
392-
klass = self.class
393-
stmt = klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.compile_update(attributes_with_values)
394-
klass.connection.update stmt
391+
392+
if attributes_with_values.empty?
393+
0
394+
else
395+
klass = self.class
396+
stmt = klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.compile_update(attributes_with_values)
397+
klass.connection.update stmt
398+
end
395399
end
396400

397401
# Creates a record with values matching those of the instance attributes

0 commit comments

Comments
 (0)