prefer to use if..end unless the condition is simple/compact

This commit is contained in:
Vijay Dev 2011-07-30 23:53:11 +05:30 committed by Xavier Noria
parent 225a2482c1
commit ad9e52f156
1 changed files with 6 additions and 4 deletions

View File

@ -1143,8 +1143,9 @@ Here's an example where we create a class with an +after_destroy+ callback for a
<ruby>
class PictureFileCallbacks
def after_destroy(picture_file)
File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
if File.exists?(picture_file.filepath)
File.delete(picture_file.filepath)
end
end
end
</ruby>
@ -1162,8 +1163,9 @@ Note that we needed to instantiate a new +PictureFileCallbacks+ object, since we
<ruby>
class PictureFileCallbacks
def self.after_destroy(picture_file)
File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
if File.exists?(picture_file.filepath)
File.delete(picture_file.filepath)
end
end
end
</ruby>